mirror of https://github.com/jumpserver/jumpserver
perf: 支持 ws
parent
7ae52eb941
commit
86a17b9955
|
@ -1,7 +1,21 @@
|
||||||
import os
|
import os
|
||||||
import django
|
|
||||||
from channels.routing import get_default_application
|
from channels.auth import AuthMiddlewareStack
|
||||||
|
from channels.routing import ProtocolTypeRouter, URLRouter
|
||||||
|
from channels.security.websocket import AllowedHostsOriginValidator
|
||||||
|
from django.core.asgi import get_asgi_application
|
||||||
|
|
||||||
|
from .routing import urlpatterns
|
||||||
|
|
||||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "jumpserver.settings")
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "jumpserver.settings")
|
||||||
django.setup()
|
application = ProtocolTypeRouter({
|
||||||
application = get_default_application()
|
# Django's ASGI application to handle traditional HTTP requests
|
||||||
|
"http": get_asgi_application(),
|
||||||
|
|
||||||
|
# WebSocket chat handler
|
||||||
|
"websocket": AllowedHostsOriginValidator(
|
||||||
|
AuthMiddlewareStack(
|
||||||
|
URLRouter(urlpatterns)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
})
|
||||||
|
|
|
@ -1,27 +1,9 @@
|
||||||
from channels.auth import AuthMiddlewareStack
|
|
||||||
from channels.routing import ProtocolTypeRouter, URLRouter
|
|
||||||
from channels.security.websocket import AllowedHostsOriginValidator
|
|
||||||
from django.core.asgi import get_asgi_application
|
|
||||||
|
|
||||||
from notifications.urls.ws_urls import urlpatterns as notifications_urlpatterns
|
from notifications.urls.ws_urls import urlpatterns as notifications_urlpatterns
|
||||||
from ops.urls.ws_urls import urlpatterns as ops_urlpatterns
|
from ops.urls.ws_urls import urlpatterns as ops_urlpatterns
|
||||||
from settings.urls.ws_urls import urlpatterns as setting_urlpatterns
|
from settings.urls.ws_urls import urlpatterns as setting_urlpatterns
|
||||||
from terminal.urls.ws_urls import urlpatterns as terminal_urlpatterns
|
from terminal.urls.ws_urls import urlpatterns as terminal_urlpatterns
|
||||||
from .middleware import WsSignatureAuthMiddleware
|
|
||||||
|
|
||||||
urlpatterns = []
|
urlpatterns = ops_urlpatterns + \
|
||||||
urlpatterns += ops_urlpatterns + \
|
notifications_urlpatterns + \
|
||||||
notifications_urlpatterns + \
|
setting_urlpatterns + \
|
||||||
setting_urlpatterns + \
|
terminal_urlpatterns
|
||||||
terminal_urlpatterns
|
|
||||||
|
|
||||||
application = ProtocolTypeRouter({
|
|
||||||
"http": get_asgi_application(),
|
|
||||||
'websocket': AllowedHostsOriginValidator(
|
|
||||||
WsSignatureAuthMiddleware(
|
|
||||||
AuthMiddlewareStack(
|
|
||||||
URLRouter(urlpatterns)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
),
|
|
||||||
})
|
|
||||||
|
|
|
@ -142,6 +142,9 @@ MIDDLEWARE = [
|
||||||
'jumpserver.middleware.EndMiddleware',
|
'jumpserver.middleware.EndMiddleware',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
if DEBUG or DEBUG_DEV:
|
||||||
|
INSTALLED_APPS.insert(0, 'daphne')
|
||||||
|
|
||||||
ROOT_URLCONF = 'jumpserver.urls'
|
ROOT_URLCONF = 'jumpserver.urls'
|
||||||
|
|
||||||
TEMPLATES = [
|
TEMPLATES = [
|
||||||
|
|
|
@ -127,7 +127,7 @@ CHANNEL_LAYERS = {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
ASGI_APPLICATION = 'jumpserver.routing.application'
|
ASGI_APPLICATION = 'jumpserver.asgi.application'
|
||||||
|
|
||||||
# Dump all celery log to here
|
# Dump all celery log to here
|
||||||
CELERY_LOG_DIR = os.path.join(PROJECT_DIR, 'data', 'celery')
|
CELERY_LOG_DIR = os.path.join(PROJECT_DIR, 'data', 'celery')
|
||||||
|
|
Loading…
Reference in New Issue