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
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);
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
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);