From 3c87b66624ff920e0ffe46d875c926aa60219fac Mon Sep 17 00:00:00 2001 From: Griatch Date: Fri, 28 Sep 2012 22:40:12 +0200 Subject: [PATCH] Set AMP interface strings to listen to local interfaces only by default. Also added AMP_INTERFACE setting. Resolves Issue 257. --- contrib/procpools/python_procpool_plugin.py | 2 +- src/server/portal.py | 2 -- src/server/server.py | 8 ++++++-- src/settings_default.py | 1 + 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/contrib/procpools/python_procpool_plugin.py b/contrib/procpools/python_procpool_plugin.py index d13447e661..47cb8bc315 100644 --- a/contrib/procpools/python_procpool_plugin.py +++ b/contrib/procpools/python_procpool_plugin.py @@ -48,7 +48,7 @@ PROCPOOL_TIMEOUT = 10 # only change if the port clashes with something else on the system PROCPOOL_PORT = 5001 # 0.0.0.0 means listening to all interfaces -PROCPOOL_INTERFACE = '0.0.0.0' +PROCPOOL_INTERFACE = '127.0.0.1' # user-id and group-id to run the processes as (for OS:es supporting this). # If you plan to run unsafe code one could experiment with setting this # to an unprivileged user. diff --git a/src/server/portal.py b/src/server/portal.py index 63c4d617e7..fb6a355e59 100644 --- a/src/server/portal.py +++ b/src/server/portal.py @@ -154,8 +154,6 @@ if AMP_ENABLED: # the portal and the mud server. Only reason to ever deactivate # it would be during testing and debugging. - print " amp (to Server): %s" % AMP_PORT - from src.server import amp factory = amp.AmpClientFactory(PORTAL) diff --git a/src/server/server.py b/src/server/server.py index b2997e3ca5..68c1a7213a 100644 --- a/src/server/server.py +++ b/src/server/server.py @@ -55,6 +55,7 @@ VERSION = get_evennia_version() AMP_ENABLED = True AMP_HOST = settings.AMP_HOST AMP_PORT = settings.AMP_PORT +AMP_INTERFACE = settings.AMP_INTERFACE # server-channel mappings IMC2_ENABLED = settings.IMC2_ENABLED @@ -306,12 +307,15 @@ if AMP_ENABLED: # the portal and the mud server. Only reason to ever deactivate # it would be during testing and debugging. - print ' amp (to Portal): %s' % AMP_PORT + ifacestr = "" + if AMP_INTERFACE != '127.0.0.1': + ifacestr = "-%s" % AMP_INTERFACE + print ' amp (to Portal)%s:%s' % (ifacestr, AMP_PORT) from src.server import amp factory = amp.AmpServerFactory(EVENNIA) - amp_service = internet.TCPServer(AMP_PORT, factory) + amp_service = internet.TCPServer(AMP_PORT, factory, interface=AMP_INTERFACE) amp_service.setName("EvenniaPortal") EVENNIA.services.addService(amp_service) diff --git a/src/settings_default.py b/src/settings_default.py index c6fb5b4554..0948855f96 100644 --- a/src/settings_default.py +++ b/src/settings_default.py @@ -110,6 +110,7 @@ ENCODINGS = ["utf-8", "latin-1", "ISO-8859-1"] # change this unless you cannot use the default AMP port/host for whatever reason. AMP_HOST = 'localhost' AMP_PORT = 5000 +AMP_INTERFACE = '127.0.0.1' # Attributes on objects are cached aggressively for speed. If the number of # objects is large (and their attributes are often accessed) this can use up a lot of # memory. So every now and then Evennia checks the size of this cache and resets