From: Matthew Wild Date: Mon, 6 Jun 2011 21:51:33 +0000 (+0100) Subject: mod_dialback: More robust handling of multiple outstanding dialback requests for... X-Git-Url: https://git.enpas.org/?a=commitdiff_plain;h=9972a0c580a93ef91ab64c7d9ceeb2543e6aca64;p=prosody.git mod_dialback: More robust handling of multiple outstanding dialback requests for the same domain, fixes intermittent s2s with some (patched?) ejabberds --- diff --git a/plugins/mod_dialback.lua b/plugins/mod_dialback.lua index 91291e24..5060f08f 100644 --- a/plugins/mod_dialback.lua +++ b/plugins/mod_dialback.lua @@ -60,7 +60,7 @@ module:hook("stanza/jabber:server:dialback:result", function(event) return true; end - dialback_requests[attr.from] = origin; + dialback_requests[attr.from.."/"..origin.streamid] = origin; if not origin.from_host then -- Just used for friendlier logging @@ -83,8 +83,8 @@ module:hook("stanza/jabber:server:dialback:verify", function(event) if origin.type == "s2sout_unauthed" or origin.type == "s2sout" then local attr = stanza.attr; - local dialback_verifying = dialback_requests[attr.from]; - if dialback_verifying then + local dialback_verifying = dialback_requests[attr.from.."/"..(attr.id or "")]; + if dialback_verifying and attr.from == origin.to_host then local valid; if attr.type == "valid" then s2s_make_authenticated(dialback_verifying, attr.from); @@ -101,7 +101,7 @@ module:hook("stanza/jabber:server:dialback:verify", function(event) st.stanza("db:result", { from = attr.to, to = attr.from, id = attr.id, type = valid }) :text(dialback_verifying.hosts[attr.from].dialback_key)); end - dialback_requests[attr.from] = nil; + dialback_requests[attr.from.."/"..(attr.id or "")] = nil; end return true; end @@ -131,22 +131,12 @@ module:hook("stanza/jabber:server:dialback:result", function(event) end end); -module:hook_stanza("urn:ietf:params:xml:ns:xmpp-sasl", "failure", function (origin, stanza) - if origin.external_auth == "failed" then - module:log("debug", "SASL EXTERNAL failed, falling back to dialback"); - s2s_initiate_dialback(origin); - return true; - end -end, 100); - module:hook_stanza(xmlns_stream, "features", function (origin, stanza) - if not origin.external_auth or origin.external_auth == "failed" then - s2s_initiate_dialback(origin); - return true; - end + s2s_initiate_dialback(origin); + return true; end, 100); -- Offer dialback to incoming hosts module:hook("s2s-stream-features", function (data) - data.features:tag("dialback", { xmlns='urn:xmpp:features:dialback' }):up(); + data.features:tag("dialback", { xmlns='urn:xmpp:features:dialback' }):tag("optional"):up():up(); end);