diff --git a/evennia/game_template/server/conf/web_plugins.py b/evennia/game_template/server/conf/web_plugins.py index 4050a82664..ec11ad7c6a 100644 --- a/evennia/game_template/server/conf/web_plugins.py +++ b/evennia/game_template/server/conf/web_plugins.py @@ -26,3 +26,16 @@ def at_webserver_root_creation(web_root): """ return web_root + + +def at_webproxy_root_creation(web_root): + """ + This function can modify the portal proxy service. + Args: + web_root (evennia.server.webserver.Website): The Evennia + Website application. Use .putChild() to add new + subdomains that are Portal-accessible over TCP; + primarily for new protocol development, but suitable + for other shenanigans. + """ + return web_root diff --git a/evennia/server/portal/portal.py b/evennia/server/portal/portal.py index 27270d7af0..5864134b46 100644 --- a/evennia/server/portal/portal.py +++ b/evennia/server/portal/portal.py @@ -95,6 +95,16 @@ INFO_DICT = { "webserver_internal": [], } +try: + WEB_PLUGINS_MODULE = mod_import(settings.WEB_PLUGINS_MODULE) +except ImportError: + WEB_PLUGINS_MODULE = None + INFO_DICT["errors"] = ( + "WARNING: settings.WEB_PLUGINS_MODULE not found - " + "copy 'evennia/game_template/server/conf/web_plugins.py to mygame/server/conf." + ) + + # ------------------------------------------------------------- # Portal Service object # ------------------------------------------------------------- @@ -380,6 +390,17 @@ if WEBSERVER_ENABLED: web_root = Website(web_root, logPath=settings.HTTP_LOG_FILE) web_root.is_portal = True + + if WEB_PLUGINS_MODULE: + try: + web_root = WEB_PLUGINS_MODULE.at_webproxy_root_creation(web_root) + except Exception as e: # Legacy user has not added an at_webproxy_root_creation function in existing web plugins file + INFO_DICT["errors"] = ( + "WARNING: WEB_PLUGINS_MODULE is enabled but at_webproxy_root_creation() not found - " + "copy 'evennia/game_template/server/conf/web_plugins.py to mygame/server/conf." + ) + + proxy_service = internet.TCPServer(proxyport, web_root, interface=interface) proxy_service.setName("EvenniaWebProxy%s:%s" % (ifacestr, proxyport)) PORTAL.services.addService(proxy_service)