-- Anything in def_env will be accessible within the session as a global variable
def_env.server = {};
-
-function def_env.server:insane_reload()
+function def_env.server:reload()
prosody.unlock_globals();
dofile "prosody"
prosody = _G.prosody;
minutes, (minutes ~= 1 and "s") or "", os.date("%c", prosody.start_time));
end
-function def_env.server:shutdown(reason)
- prosody.shutdown(reason);
- return true, "Shutdown initiated";
-end
-
def_env.module = {};
local function get_hosts_set(hosts, module)
return ok, (ok and "Module reloaded on "..count.." host"..(count ~= 1 and "s" or "")) or ("Last error: "..tostring(err));
end
+function def_env.module:list(hosts)
+ if hosts == nil then
+ hosts = array.collect(keys(prosody.hosts));
+ end
+ if type(hosts) == "string" then
+ hosts = { hosts };
+ end
+ if type(hosts) ~= "table" then
+ return false, "Please supply a host or a list of hosts you would like to see";
+ end
+
+ local print = self.session.print;
+ for _, host in ipairs(hosts) do
+ print(host..":");
+ local modules = array.collect(keys(prosody.hosts[host].modules or {})):sort();
+ if #modules == 0 then
+ print(" No modules loaded");
+ else
+ for _, name in ipairs(modules) do
+ print(" "..name);
+ end
+ end
+ end
+end
+
def_env.config = {};
function def_env.config:load(filename, format)
local config_load = require "core.configmanager".load;
return true, tostring(config_get(host, section, key));
end
-function def_env.config:reload()
- local ok, err = prosody.reload_config();
- return ok, (ok and "Config reloaded (you may need to reload modules to take effect)") or tostring(err);
-end
-
def_env.hosts = {};
function def_env.hosts:list()
for host, host_session in pairs(hosts) do
if not session then
print("No outgoing connection from "..from.." to "..to)
else
- s2smanager.destroy_session(session);
+ (session.close or s2smanager.destroy_session)(session);
count = count + 1;
print("Closed outgoing session from "..from.." to "..to);
end
-- Is an incoming connection
for session in pairs(incoming_s2s) do
if session.to_host == to and session.from_host == from then
- s2smanager.destroy_session(session);
+ (session.close or s2smanager.destroy_session)(session);
count = count + 1;
end
end