diff options
author | Matthew Wild <mwild1@gmail.com> | 2009-06-07 14:19:36 +0100 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2009-06-07 14:19:36 +0100 |
commit | e9c388582baab737b5aa092674bf8fb43a5a9e60 (patch) | |
tree | 5363ab1ef0780bc4038665de1b4b9149ae8fe4f4 | |
parent | 2ef63904d65d0883e2687aa3d23bcbecf80f920e (diff) | |
parent | 2c8f13edc6e93b58c6e21fe8cb46bd3a84221a8b (diff) | |
download | prosody-e9c388582baab737b5aa092674bf8fb43a5a9e60.tar.gz prosody-e9c388582baab737b5aa092674bf8fb43a5a9e60.zip |
Automated merge with http://waqas.ath.cx:8000/
-rw-r--r-- | core/modulemanager.lua | 11 | ||||
-rw-r--r-- | plugins/mod_console.lua | 8 |
2 files changed, 19 insertions, 0 deletions
diff --git a/core/modulemanager.lua b/core/modulemanager.lua index 748c7dce..187e4d6e 100644 --- a/core/modulemanager.lua +++ b/core/modulemanager.lua @@ -373,6 +373,17 @@ function api:hook(event, handler, priority) (hosts[self.host] or prosody).events.add_handler(event, handler, priority); end +function api:hook_stanza(xmlns, name, handler, priority) + if not handler and type(name) == "function" then + -- If only 2 options then they specified no xmlns + xmlns, name, handler, priority = nil, xmlns, name, handler; + elseif not (handler and name) then + self:log("warn", "Error: Insufficient parameters to module:hook_stanza()"); + return; + end + return api.hook(self, "stanza/"..(xmlns and (xmlns..":") or "")..name, function (data) return handler(data.origin, data.stanza, data); end, priority); +end + -------------------------------------------------------------------- local actions = {}; diff --git a/plugins/mod_console.lua b/plugins/mod_console.lua index c676c0eb..77d76a82 100644 --- a/plugins/mod_console.lua +++ b/plugins/mod_console.lua @@ -318,10 +318,14 @@ def_env.s2s = {}; function def_env.s2s:show(match_jid) local _print = self.session.print; local print = self.session.print; + + local count_in, count_out = 0,0; + for host, host_session in pairs(hosts) do print = function (...) _print(host); _print(...); print = _print; end 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); if session.sendq then print(" There are "..#session.sendq.." queued outgoing stanzas for this connection"); @@ -354,6 +358,7 @@ function def_env.s2s:show(match_jid) 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 + count_in = count_in + 1; print(" "..host.." <- "..(session.from_host or "(unknown)")); if session.type == "s2sin_unauthed" then print(" Connection not yet authenticated"); @@ -371,10 +376,13 @@ function def_env.s2s:show(match_jid) for session in pairs(incoming_s2s) do if not session.to_host and ((not match_jid) or session.from_host and session.from_host:match(match_jid)) then + count_in = count_in + 1; print("Other incoming s2s connections"); print(" (unknown) <- "..(session.from_host or "(unknown)")); end end + + return true, "Total: "..count_out.." outgoing, "..count_in.." incoming connections"; end ------------- |