From c083fe6266eddee8db14f6b1cc0b6cb98a289c55 Mon Sep 17 00:00:00 2001 From: Griatch Date: Thu, 23 May 2013 22:58:50 +0200 Subject: [PATCH] Webserver->Server is working, some more cleanup needed. --- src/server/portal/portal.py | 19 ++++++++++++------- src/server/portal/webclient.py | 10 +++++----- src/server/server.py | 6 +++--- src/settings_default.py | 10 +++++++--- 4 files changed, 27 insertions(+), 18 deletions(-) diff --git a/src/server/portal/portal.py b/src/server/portal/portal.py index 6f71d6832b..a39618f6e3 100644 --- a/src/server/portal/portal.py +++ b/src/server/portal/portal.py @@ -55,7 +55,8 @@ WEBCLIENT_ENABLED = settings.WEBCLIENT_ENABLED AMP_HOST = settings.AMP_HOST AMP_PORT = settings.AMP_PORT -AMP_ENABLED = AMP_HOST and AMP_PORT +AMP_INTERFACE = settings.AMP_INTERFACE +AMP_ENABLED = AMP_HOST and AMP_PORT and AMP_INTERFACE #------------------------------------------------------------ @@ -156,6 +157,11 @@ if AMP_ENABLED: from src.server import amp + ifacestr = "" + if AMP_HOST != '127.0.0.1': + ifacestr = "-%s" % AMP_HOST + print ' amp (to Server)%s: %s' % (ifacestr, AMP_PORT) + factory = amp.AmpClientFactory(PORTAL) amp_client = internet.TCPClient(AMP_HOST, AMP_PORT, factory) amp_client.setName('evennia_amp') @@ -251,10 +257,9 @@ if WEBSERVER_ENABLED: ifacestr = "" if interface != '0.0.0.0' or len(WEBSERVER_INTERFACES) > 1: ifacestr = "-%s" % interface - for port in WEBSERVER_PORTS: - pstring = "%s:%s" % (ifacestr, port) - web_root = proxy.ReverseProxyResource("localhost", port, '') - + for proxyport, serverport in WEBSERVER_PORTS: + pstring = "%s:%s<->%s" % (ifacestr, proxyport, serverport) + web_root = proxy.ReverseProxyResource('127.0.0.1', serverport, '') webclientstr = "" if WEBCLIENT_ENABLED: # create ajax client processes at /webclientdata @@ -265,10 +270,10 @@ if WEBSERVER_ENABLED: webclientstr = "/client" web_root = server.Site(web_root, logPath=settings.HTTP_LOG_FILE) - proxy_service = internet.TCPServer(port+1, web_root) + proxy_service = internet.TCPServer(proxyport, web_root, interface=interface) proxy_service.setName('EvenniaWebProxy%s' % pstring) PORTAL.services.addService(proxy_service) - print " webproxy%s%s: %s" % (webclientstr, ifacestr, port+1) + print " webproxy%s%s:%s (<-> %s)" % (webclientstr, ifacestr, proxyport, serverport) for plugin_module in PORTAL_SERVICES_PLUGIN_MODULES: # external plugin services to start diff --git a/src/server/portal/webclient.py b/src/server/portal/webclient.py index afdbd49f2c..746d20d749 100644 --- a/src/server/portal/webclient.py +++ b/src/server/portal/webclient.py @@ -63,11 +63,11 @@ class WebClient(resource.Resource): self.requests = {} self.databuffer = {} - def getChild(self, path, request): - """ - This is the place to put dynamic content. - """ - return self + #def getChild(self, path, request): + # """ + # This is the place to put dynamic content. + # """ + # return self def _responseFailed(self, failure, suid, request): "callback if a request is lost/timed out" diff --git a/src/server/server.py b/src/server/server.py index 8836f1a0f0..1e33daf04a 100644 --- a/src/server/server.py +++ b/src/server/server.py @@ -330,7 +330,7 @@ if AMP_ENABLED: ifacestr = "" if AMP_INTERFACE != '127.0.0.1': ifacestr = "-%s" % AMP_INTERFACE - print ' amp (to Portal)%s:%s' % (ifacestr, AMP_PORT) + print ' amp (to Portal)%s: %s' % (ifacestr, AMP_PORT) from src.server import amp @@ -361,9 +361,9 @@ if WEBSERVER_ENABLED: ifacestr = "" if interface != '0.0.0.0' or len(WEBSERVER_INTERFACES) > 1: ifacestr = "-%s" % interface - for port in WEBSERVER_PORTS: + for proxyport, port in WEBSERVER_PORTS: + # create the webserver (we only need the port for this) pstring = "%s:%s" % (ifacestr, port) - # create the webserver webserver = WSGIWebServer(threads, port, web_site, interface=interface) webserver.setName('EvenniaWebServer%s' % pstring) EVENNIA.services.addService(webserver) diff --git a/src/settings_default.py b/src/settings_default.py index 626d559804..2e4bbed358 100644 --- a/src/settings_default.py +++ b/src/settings_default.py @@ -44,8 +44,12 @@ WEBSERVER_ENABLED = True # attacks. It defaults to allowing all. In production, make # sure to change this to your actual host addresses/IPs. ALLOWED_HOSTS = ["*"] -# A list of ports the Evennia webserver listens on -WEBSERVER_PORTS = [8000] +# The webserver sits behind a Portal proxy. This is a list +# of tuples (proxyport,serverport) used. The proxyports are what +# the Portal proxy presents to the world. The serverports are +# the internal ports the proxy uses to forward data to the Server-side +# webserver (these should not be publicly open) +WEBSERVER_PORTS = [(8000, 5001)] # Interface addresses to listen to. If 0.0.0.0, listen to all. WEBSERVER_INTERFACES = ['0.0.0.0'] # IP addresses that may talk to the server in a reverse proxy configuration, @@ -111,7 +115,7 @@ ENCODINGS = ["utf-8", "latin-1", "ISO-8859-1"] # communicate with it. This is an internal functionality of Evennia, usually # operating between two processes on the same machine. You usually don't need to # change this unless you cannot use the default AMP port/host for whatever reason. -AMP_HOST = 'localhost' +AMP_HOST = '127.0.0.1' AMP_PORT = 5000 AMP_INTERFACE = '127.0.0.1' # Caching speeds up all forms of database access, often considerably. There