aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_console.lua
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/mod_console.lua')
-rw-r--r--plugins/mod_console.lua35
1 files changed, 29 insertions, 6 deletions
diff --git a/plugins/mod_console.lua b/plugins/mod_console.lua
index b9d30716..5472eb91 100644
--- a/plugins/mod_console.lua
+++ b/plugins/mod_console.lua
@@ -70,6 +70,9 @@ function console_listener.listener(conn, data)
if data:match("^>") then
data = data:gsub("^>", "");
useglobalenv = true;
+ elseif data == "\004" then
+ commands["bye"](session, data);
+ return;
else
local command = data:lower();
command = data:match("^%w+") or data:match("%p");
@@ -206,7 +209,8 @@ end
-- Anything in def_env will be accessible within the session as a global variable
def_env.server = {};
-function def_env.server:reload()
+
+function def_env.server:insane_reload()
prosody.unlock_globals();
dofile "prosody"
prosody = _G.prosody;
@@ -231,6 +235,11 @@ function def_env.server:uptime()
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)
@@ -359,6 +368,11 @@ function def_env.config:get(host, section, key)
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
@@ -385,7 +399,12 @@ end
function def_env.c2s:show(match_jid)
local print, count = self.session.print, 0;
+ local curr_host;
show_c2s(function (jid, session)
+ if curr_host ~= session.host then
+ curr_host = session.host;
+ print(curr_host);
+ end
if (not match_jid) or jid:match(match_jid) then
count = count + 1;
local status, priority = "unavailable", tostring(session.priority or "-");
@@ -397,7 +416,7 @@ function def_env.c2s:show(match_jid)
status = "available";
end
end
- print(jid.." - "..status.."("..priority..")");
+ print(" "..jid.." - "..status.."("..priority..")");
end
end);
return true, "Total: "..count.." clients";
@@ -448,7 +467,7 @@ function def_env.s2s:show(match_jid)
for remotehost, session in pairs(host_session.s2sout) do
if (not match_jid) or remotehost:match(match_jid) or host:match(match_jid) then
count_out = count_out + 1;
- print(" "..host.." -> "..remotehost);
+ print(" "..host.." -> "..remotehost..(session.secure and " (encrypted)" or ""));
if session.sendq then
print(" There are "..#session.sendq.." queued outgoing stanzas for this connection");
end
@@ -476,12 +495,16 @@ function def_env.s2s:show(match_jid)
end
end
end
-
+ local subhost_filter = function (h)
+ return (match_jid and h:match(match_jid));
+ end
for session in pairs(incoming_s2s) do
if session.to_host == host and ((not match_jid) or host:match(match_jid)
- or (session.from_host and session.from_host:match(match_jid))) then
+ or (session.from_host and session.from_host:match(match_jid))
+ -- Pft! is what I say to list comprehensions
+ or (session.hosts and #array.collect(keys(session.hosts)):filter(subhost_filter)>0)) then
count_in = count_in + 1;
- print(" "..host.." <- "..(session.from_host or "(unknown)"));
+ print(" "..host.." <- "..(session.from_host or "(unknown)")..(session.secure and " (encrypted)" or ""));
if session.type == "s2sin_unauthed" then
print(" Connection not yet authenticated");
end