From 5429ede5f7620c94ea0bd8e9a2ac89ef8863871f Mon Sep 17 00:00:00 2001 From: Griatch Date: Sun, 27 Sep 2015 09:57:23 +0200 Subject: [PATCH] Changed how the webclient looks up the webcocket_url. This auto-lookups the url while still respecting a custom given settings.WEBSOCKET_CLIENT_URL (for proxy setups?). This means settings.WEBSOCKET_CLIENT_URL is now defaulting to None. Resolves #806. --- evennia/settings_default.py | 9 ++++++--- evennia/web/utils/general_context.py | 6 ++++-- evennia/web/webclient/templates/webclient.html | 6 +++++- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/evennia/settings_default.py b/evennia/settings_default.py index adede4f79d..51909d8088 100644 --- a/evennia/settings_default.py +++ b/evennia/settings_default.py @@ -71,9 +71,12 @@ WEBSOCKET_CLIENT_ENABLED = True WEBSOCKET_CLIENT_PORT = 8001 # Interface addresses to listen to. If 0.0.0.0, listen to all. Use :: for IPv6. WEBSOCKET_CLIENT_INTERFACE = '0.0.0.0' -# Actual URL for webclient component to reach the websocket. -# The WEBSOCKET_CLIENT_PORT will be automatically appended to this URL. -WEBSOCKET_CLIENT_URL = "ws://localhost" +# Actual URL for webclient component to reach the websocket. You only need +# to set this if you know you need it, like using some sort of proxy setup. +# If given it must be on the form "ws://hostname" (WEBSOCKET_CLIENT_PORT will +# be automatically appended). If left at None, the client will itself +# figure out this url based on the server's hostname. +WEBSOCKET_CLIENT_URL = None # Activate SSH protocol communication (SecureShell) SSH_ENABLED = False # Ports to use for SSH diff --git a/evennia/web/utils/general_context.py b/evennia/web/utils/general_context.py index dfd35772c1..b34438546b 100644 --- a/evennia/web/utils/general_context.py +++ b/evennia/web/utils/general_context.py @@ -31,7 +31,8 @@ WEBSITE = ['Flatpages', 'News', 'Sites'] # The main context processor function WEBCLIENT_ENABLED = settings.WEBCLIENT_ENABLED WEBSOCKET_CLIENT_ENABLED = settings.WEBSOCKET_CLIENT_ENABLED -WSURL = "%s:%s" % (settings.WEBSOCKET_CLIENT_URL, settings.WEBSOCKET_CLIENT_PORT) +WEBSOCKET_PORT = settings.WEBSOCKET_CLIENT_PORT +WEBSOCKET_URL = settings.WEBSOCKET_CLIENT_URL def general_context(request): """ @@ -48,5 +49,6 @@ def general_context(request): 'evennia_websiteapps':WEBSITE, "webclient_enabled" : WEBCLIENT_ENABLED, "websocket_enabled" : WEBSOCKET_CLIENT_ENABLED, - "websocket_url" : WSURL + "websocket_port" : WEBSOCKET_PORT, + "websocket_url" : WEBSOCKET_URL } diff --git a/evennia/web/webclient/templates/webclient.html b/evennia/web/webclient/templates/webclient.html index 9984f9c42a..0abbb19bd1 100644 --- a/evennia/web/webclient/templates/webclient.html +++ b/evennia/web/webclient/templates/webclient.html @@ -24,7 +24,11 @@