diff options
-rw-r--r-- | core/modulemanager.lua | 20 | ||||
-rw-r--r-- | core/s2smanager.lua | 2 | ||||
-rw-r--r-- | net/xmppclient_listener.lua | 2 | ||||
-rw-r--r-- | net/xmppserver_listener.lua | 2 | ||||
-rw-r--r-- | plugins/mod_console.lua | 32 |
5 files changed, 52 insertions, 6 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 diff --git a/net/xmppclient_listener.lua b/net/xmppclient_listener.lua index 0f5511b4..369860e2 100644 --- a/net/xmppclient_listener.lua +++ b/net/xmppclient_listener.lua @@ -19,7 +19,7 @@ local st = stanza; local stream_callbacks = { streamopened = sm_streamopened, streamclosed = sm_streamclosed }; local sessions = {}; -local xmppclient = { default_port = 5222 }; +local xmppclient = { default_port = 5222, default_mode = "*a" }; -- These are session methods -- diff --git a/net/xmppserver_listener.lua b/net/xmppserver_listener.lua index cd9a3460..3364f90b 100644 --- a/net/xmppserver_listener.lua +++ b/net/xmppserver_listener.lua @@ -21,7 +21,7 @@ local sm_new_session, sm_destroy_session = sessionmanager.new_session, sessionma local st = stanza; local sessions = {}; -local xmppserver = { default_port = 5269 }; +local xmppserver = { default_port = 5269, default_mode = "*a" }; -- These are session methods -- diff --git a/plugins/mod_console.lua b/plugins/mod_console.lua index 4471dccb..b1dc263c 100644 --- a/plugins/mod_console.lua +++ b/plugins/mod_console.lua @@ -37,7 +37,7 @@ function console_listener.listener(conn, data) -- Handle new connection
session = console:new_session(conn);
sessions[conn] = session;
- session.print("Welcome to the lxmppd admin console!");
+ printbanner(session);
end
if data then
-- Handle data
@@ -129,15 +129,24 @@ function def_env.server:reload() end
def_env.module = {};
-function def_env.module:load(name)
+function def_env.module:load(name, host, config)
local mm = require "modulemanager";
- local ok, err = mm.load(name);
+ local ok, err = mm.load(host or self.env.host, name, config);
if not ok then
return false, err or "Unknown error loading module";
end
return true, "Module loaded";
end
+function def_env.module:unload(name, host)
+ local mm = require "modulemanager";
+ local ok, err = mm.unload(host or self.env.host, name);
+ if not ok then
+ return false, err or "Unknown error unloading module";
+ end
+ return true, "Module unloaded";
+end
+
def_env.config = {};
function def_env.config:load(filename, format)
local config_load = require "core.configmanager".load;
@@ -163,3 +172,20 @@ end function def_env.hosts:add(name)
end
+
+-------------
+
+function printbanner(session)
+session.print [[
+ ____ \ / _
+ | _ \ _ __ ___ ___ _-_ __| |_ _
+ | |_) | '__/ _ \/ __|/ _ \ / _` | | | |
+ | __/| | | (_) \__ \ |_| | (_| | |_| |
+ |_| |_| \___/|___/\___/ \__,_|\__, |
+ A study in simplicity |___/
+
+]]
+session.print("Welcome to the Prosody administration console. For a list of commands, type: help");
+session.print("You may find more help on using this console in our online documentation at ");
+session.print("http://prosody.im/doc/console\n");
+end
|