Make ejabberd2prosody.lua eecutable
[prosody.git] / plugins / mod_dialback.lua
index d7697535241aaa84599a7e0c83de4e6b2999d82f..e7804962adab33a0ac591f46b1c6d86d17c8f5c0 100644 (file)
@@ -8,7 +8,7 @@ local log = require "util.logger".init("mod_dialback");
 
 local xmlns_dialback = "jabber:server:dialback";
 
-add_handler({"s2sin_unauthed", "s2sin"}, "verify", xmlns_dialback,
+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
                log("debug", "verifying dialback key...");
@@ -26,7 +26,7 @@ add_handler({"s2sin_unauthed", "s2sin"}, "verify", xmlns_dialback,
                origin.sends2s(format("<db:verify from='%s' to='%s' id='%s' type='%s'>%s</db:verify>", attr.to, attr.from, attr.id, type, stanza[1]));
        end);
 
-add_handler("s2sin_unauthed", "result", xmlns_dialback,
+module: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
@@ -42,7 +42,7 @@ add_handler("s2sin_unauthed", "result", xmlns_dialback,
                hosts[origin.to_host].s2sout[origin.from_host].dialback_verifying = origin;
        end);
 
-add_handler({ "s2sout_unauthed", "s2sout" }, "verify", xmlns_dialback,
+module:add_handler({ "s2sout_unauthed", "s2sout" }, "verify", xmlns_dialback,
        function (origin, stanza)
                if origin.dialback_verifying then
                        local valid;
@@ -56,15 +56,15 @@ add_handler({ "s2sout_unauthed", "s2sout" }, "verify", xmlns_dialback,
                                valid = "invalid";
                        end
                        if not origin.dialback_verifying.sends2s then
-                               log("warn", "Incoming s2s session was closed in the meantime, so we can't notify it of the db result");
+                               log("warn", "Incoming s2s session %s was closed in the meantime, so we can't notify it of the db result", tostring(origin.dialback_verifying):match("%w+$"));
                        else
                                origin.dialback_verifying.sends2s(format("<db:result from='%s' to='%s' id='%s' type='%s'>%s</db:result>",
-                                       attr.from, attr.to, attr.id, valid, origin.dialback_verifying.dialback_key));
+                                       attr.to, attr.from, attr.id, valid, origin.dialback_verifying.dialback_key));
                        end
                end
        end);
 
-add_handler({ "s2sout_unauthed", "s2sout" }, "result", xmlns_dialback,
+module:add_handler({ "s2sout_unauthed", "s2sout" }, "result", xmlns_dialback,
        function (origin, stanza)
                if stanza.attr.type == "valid" then
                        s2s_make_authenticated(origin);