diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/modulemanager.lua | 19 | ||||
-rw-r--r-- | core/s2smanager.lua | 2 | ||||
-rw-r--r-- | core/sessionmanager.lua | 2 |
3 files changed, 14 insertions, 9 deletions
diff --git a/core/modulemanager.lua b/core/modulemanager.lua index 1382e227..3c27e7a0 100644 --- a/core/modulemanager.lua +++ b/core/modulemanager.lua @@ -44,7 +44,7 @@ module "modulemanager" local api = {}; -- Module API container -local modulemap = {}; +local modulemap = { ["*"] = {} }; local stanza_handlers = multitable_new(); local handler_info = {}; @@ -67,19 +67,23 @@ function load(host, module_name, config) if not (host and module_name) then return nil, "insufficient-parameters"; end - local mod, err = loadfile(plugin_dir.."mod_"..module_name..".lua"); - if not mod then - log("error", "Unable to load module '%s': %s", module_name or "nil", err or "nil"); - return nil, err; - end if not modulemap[host] then modulemap[host] = {}; elseif modulemap[host][module_name] then log("warn", "%s is already loaded for %s, so not loading again", module_name, host); return nil, "module-already-loaded"; + elseif modulemap["*"][module_name] then + return nil, "global-module-already-loaded"; end + + local mod, err = loadfile(plugin_dir.."mod_"..module_name..".lua"); + if not mod then + log("error", "Unable to load module '%s': %s", module_name or "nil", err or "nil"); + return nil, err; + end + local _log = logger.init(host..":"..module_name); local api_instance = setmetatable({ name = module_name, host = host, config = config, _log = _log, log = function (self, ...) return _log(...); end }, { __index = api }); @@ -93,7 +97,8 @@ function load(host, module_name, config) return nil, ret; end - modulemap[host][module_name] = mod; + -- Use modified host, if the module set one + modulemap[api_instance.host][module_name] = mod; return true; end diff --git a/core/s2smanager.lua b/core/s2smanager.lua index 5eb28b50..ae834a9c 100644 --- a/core/s2smanager.lua +++ b/core/s2smanager.lua @@ -94,7 +94,7 @@ function new_incoming(conn) local session = { conn = conn, type = "s2sin_unauthed", direction = "incoming" }; if true then session.trace = newproxy(true); - getmetatable(session.trace).__gc = function () open_sessions = open_sessions - 1; print("s2s session got collected, now "..open_sessions.." s2s sessions are allocated") end; + getmetatable(session.trace).__gc = function () open_sessions = open_sessions - 1; end; end open_sessions = open_sessions + 1; local w, log = conn.write, logger_init("s2sin"..tostring(conn):match("[a-f0-9]+$")); diff --git a/core/sessionmanager.lua b/core/sessionmanager.lua index 74a17fe5..a597e724 100644 --- a/core/sessionmanager.lua +++ b/core/sessionmanager.lua @@ -52,7 +52,7 @@ function new_session(conn) local session = { conn = conn, priority = 0, type = "c2s_unauthed", conntime = gettime() }; if true then session.trace = newproxy(true); - getmetatable(session.trace).__gc = function () open_sessions = open_sessions - 1; print("Session got collected, now "..open_sessions.." sessions are allocated") end; + getmetatable(session.trace).__gc = function () open_sessions = open_sessions - 1; end; end open_sessions = open_sessions + 1; log("info", "open sessions now: ".. open_sessions); |