diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/modulemanager.lua | 20 | ||||
-rw-r--r-- | core/s2smanager.lua | 2 |
2 files changed, 21 insertions, 1 deletions
diff --git a/core/modulemanager.lua b/core/modulemanager.lua index 704bd26f..ce34f3e6 100644 --- a/core/modulemanager.lua +++ b/core/modulemanager.lua @@ -27,6 +27,9 @@ local modulehelpers = setmetatable({}, { __index = _G }); function load(host, module_name, config) + if not (host and module_name) then + return nil, "insufficient-parameters"; + end local mod, err = loadfile("plugins/mod_"..module_name..".lua"); if not mod then log("error", "Unable to load module '%s': %s", module_name or "nil", err or "nil"); @@ -59,6 +62,23 @@ function load(host, module_name, config) return true; end +function is_loaded(host, name) + return modulemap[host] and modulemap[host][name] and true; +end + +function unload(host, name, ...) + local mod = modulemap[host] and modulemap[host][name]; + if not mod then return nil, "module-not-loaded"; end + + if type(mod.unload) == "function" then + local ok, err = pcall(mod.unload, ...) + if (not ok) and err then + log("warn", "Non-fatal error unloading module '%s' from '%s': %s", name, host, err); + end + end + +end + function handle_stanza(host, origin, stanza) local name, xmlns, origin_type = stanza.name, stanza.attr.xmlns, origin.type; diff --git a/core/s2smanager.lua b/core/s2smanager.lua index 1cd40aa8..80e68ccc 100644 --- a/core/s2smanager.lua +++ b/core/s2smanager.lua @@ -143,7 +143,7 @@ function attempt_connection(host_session, err) end local cl = connlisteners_get("xmppserver"); - conn = wraptlsclient(cl, conn, connect_host, connect_port, 0, 1, hosts[from_host].ssl_ctx ); + conn = wraptlsclient(cl, conn, connect_host, connect_port, 0, cl.default_mode or 1, hosts[from_host].ssl_ctx ); host_session.conn = conn; -- Register this outgoing connection so that xmppserver_listener knows about it |