-add_handler("s2sin_unauthed", "result", xmlns_dialback,
- function (origin, stanza)
- -- he wants to be identified through dialback
- -- We need to check the key with the Authoritative server
- local attr = stanza.attr;
- local attr = stanza.attr;
+module:add_handler({"s2sin_unauthed", "s2sin"}, "verify", xmlns_dialback,
+ function (origin, stanza)
+ -- We are being asked to verify the key, to ensure it was generated by us
+ origin.log("debug", "verifying that dialback key is ours...");
+ local attr = stanza.attr;
+ -- COMPAT: Grr, ejabberd breaks this one too?? it is black and white in XEP-220 example 34
+ --if attr.from ~= origin.to_host then error("invalid-from"); end
+ local type;
+ if s2s_verify_dialback(attr.id, attr.from, attr.to, stanza[1]) then
+ type = "valid"
+ else
+ type = "invalid"
+ origin.log("warn", "Asked to verify a dialback key that was incorrect. An imposter is claiming to be %s?", attr.to);
+ end
+ origin.log("debug", "verified dialback key... it is %s", type);
+ origin.sends2s(st.stanza("db:verify", { from = attr.to, to = attr.from, id = attr.id, type = type }):text(stanza[1]));
+ end);
+
+module:add_handler({ "s2sin_unauthed", "s2sin" }, "result", xmlns_dialback,
+ function (origin, stanza)
+ -- 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] };
+
+ if not hosts[attr.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:close("host-unknown");
+ return;
+ end
+
+ dialback_requests[attr.from] = origin;
+
+ if not origin.from_host then
+ -- Just used for friendlier logging