From 75d9d9e997d8f88e483f3c79305fe0d79fb90c9a Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Thu, 10 May 2012 22:59:01 +0100 Subject: mod_s2s, s2smanager, mod_dialback: Move addition of session.send() on s2sin to after they are authenticated (thus from mod_s2s to s2smanager). Update mod_dialback to fire route/remote directly, as session.send() is no longer available for s2sin_unauthed. Fixes #291. --- plugins/mod_dialback.lua | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'plugins/mod_dialback.lua') diff --git a/plugins/mod_dialback.lua b/plugins/mod_dialback.lua index 35186c5e..8f69b55a 100644 --- a/plugins/mod_dialback.lua +++ b/plugins/mod_dialback.lua @@ -64,28 +64,29 @@ module:hook("stanza/jabber:server:dialback:result", function(event) -- he wants to be identified through dialback -- We need to check the key with the Authoritative server local attr = stanza.attr; - origin.hosts[attr.from] = { dialback_key = stanza[1] }; + local to, from = attr.to, attr.from; - if not hosts[attr.to] then + origin.hosts[from] = { dialback_key = stanza[1] }; + + if not hosts[to] then -- Not a host that we serve - origin.log("info", "%s tried to connect to %s, which we don't serve", attr.from, attr.to); + origin.log("info", "%s tried to connect to %s, which we don't serve", from, to); origin:close("host-unknown"); return true; end - dialback_requests[attr.from.."/"..origin.streamid] = origin; + dialback_requests[from.."/"..origin.streamid] = origin; - if not origin.from_host then - -- Just used for friendlier logging - origin.from_host = attr.from; - end - if not origin.to_host then - -- Just used for friendlier logging - origin.to_host = attr.to; - end + -- COMPAT: ejabberd, gmail and perhaps others do not always set 'to' and 'from' + -- on streams. We fill in the session's to/from here instead. + if not origin.from_host then origin.from_host = from; end + if not origin.to_host then origin.to_host = to; end - origin.log("debug", "asking %s if key %s belongs to them", attr.from, stanza[1]); - origin.send(st.stanza("db:verify", { from = attr.to, to = attr.from, id = origin.streamid }):text(stanza[1])); + origin.log("debug", "asking %s if key %s belongs to them", from, stanza[1]); + module:fire_event("route/remote", { + from_host = to, to_host = from; + stanza = st.stanza("db:verify", { from = to, to = from, id = origin.streamid }):text(stanza[1]); + }); return true; end end); -- cgit v1.2.3