# HG changeset patch # User Matthew Wild # Date 1244380776 -3600 # Node ID 0709c9564b1c0daf99aaf3d10b1cf310db8aaca9 # Parent 20285e9d71ee6c114eb5a56ff7706c562a5d0dd1# Parent 33d103b0283f5b8d1789e7bf36885548035a04d9 Automated merge with http://waqas.ath.cx:8000/ diff -r 20285e9d71ee -r 0709c9564b1c core/modulemanager.lua --- a/core/modulemanager.lua Sun Jun 07 18:06:01 2009 +0500 +++ b/core/modulemanager.lua Sun Jun 07 14:19:36 2009 +0100 @@ -373,6 +373,17 @@ (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 -r 20285e9d71ee -r 0709c9564b1c plugins/mod_console.lua --- a/plugins/mod_console.lua Sun Jun 07 18:06:01 2009 +0500 +++ b/plugins/mod_console.lua Sun Jun 07 14:19:36 2009 +0100 @@ -318,10 +318,14 @@ 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 @@ 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 @@ 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 -------------