# HG changeset patch # User Waqas Hussain # Date 1244796391 -18000 # Node ID d74441a2f3e8ae1410618db8a81831e0876cb002 # Parent f7fed9f774557f764887f7199f1d227a20471b09# Parent baad431dabc5630130fa6aecc2bd63e4dd45e78d Merge diff -r f7fed9f77455 -r d74441a2f3e8 core/modulemanager.lua --- a/core/modulemanager.lua Fri Jun 12 13:06:41 2009 +0500 +++ b/core/modulemanager.lua Fri Jun 12 13:46:31 2009 +0500 @@ -128,7 +128,7 @@ local success, ret = pcall(mod); if not success then - log("error", "Error initialising module '%s': %s", name or "nil", ret or "nil"); + log("error", "Error initialising module '%s': %s", module_name or "nil", ret or "nil"); return nil, ret; end @@ -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 f7fed9f77455 -r d74441a2f3e8 plugins/mod_console.lua --- a/plugins/mod_console.lua Fri Jun 12 13:06:41 2009 +0500 +++ b/plugins/mod_console.lua Fri Jun 12 13:46:31 2009 +0500 @@ -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 ------------- diff -r f7fed9f77455 -r d74441a2f3e8 plugins/mod_message.lua --- a/plugins/mod_message.lua Fri Jun 12 13:06:41 2009 +0500 +++ b/plugins/mod_message.lua Fri Jun 12 13:46:31 2009 +0500 @@ -2,6 +2,7 @@ local full_sessions = full_sessions; local bare_sessions = bare_sessions; +local st = require "util.stanza"; local jid_bare = require "util.jid".bare; local jid_split = require "util.jid".split; local user_exists = require "core.usermanager".user_exists;