diff options
author | Matthew Wild <mwild1@gmail.com> | 2009-05-30 15:25:27 +0100 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2009-05-30 15:25:27 +0100 |
commit | d05f7a417992dd0515253bedb2f2a5246b358d8e (patch) | |
tree | 1fffcf80dee6a191d50267bbb40f119d57589b30 /plugins/mod_console.lua | |
parent | fa6878c198ac961a0405309077ace4e2d89fb200 (diff) | |
download | prosody-d05f7a417992dd0515253bedb2f2a5246b358d8e.tar.gz prosody-d05f7a417992dd0515253bedb2f2a5246b358d8e.zip |
mod_console: c2s:show(), c2s:show_secure(), c2s:show_insecure()
Diffstat (limited to 'plugins/mod_console.lua')
-rw-r--r-- | plugins/mod_console.lua | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/plugins/mod_console.lua b/plugins/mod_console.lua index 4b715b23..a95eb5dc 100644 --- a/plugins/mod_console.lua +++ b/plugins/mod_console.lua @@ -194,6 +194,53 @@ end function def_env.hosts:add(name) end +def_env.c2s = {}; + +local function show_c2s(callback) + for hostname, host in pairs(hosts) do + for username, user in pairs(host.sessions or {}) do + for resource, session in pairs(user.sessions or {}) do + local jid = username.."@"..hostname.."/"..resource; + callback(jid, session); + end + end + end +end + +function def_env.c2s:show(match_jid) + local print, count = self.session.print, 0; + show_c2s(function (jid) + if (not match_jid) or jid:match(match_jid) then + count = count + 1; + print(jid); + end + end); + return true, "Total: "..count.." clients"; +end + +function def_env.c2s:show_insecure(match_jid) + local print, count = self.session.print, 0; + show_c2s(function (jid, session) + if ((not match_jid) or jid:match(match_jid)) and not session.secure then + count = count + 1; + print(jid); + end + end); + return true, "Total: "..count.." insecure client connections"; +end + +function def_env.c2s:show_secure(match_jid) + local print, count = self.session.print, 0; + show_c2s(function (jid, session) + if ((not match_jid) or jid:match(match_jid)) and session.secure then + count = count + 1; + print(jid); + end + end); + return true, "Total: "..count.." secure client connections"; +end + + def_env.s2s = {}; function def_env.s2s:show(match_jid) local _print = self.session.print; |