Merge from waqas
[prosody.git] / plugins / mod_dialback.lua
index 87ac303b65a75a00a10a68e447b86d41e8614ed9..ea0f9e91c7af104b94e907def2bad822aa227a30 100644 (file)
@@ -1,3 +1,23 @@
+-- Prosody IM v0.1
+-- Copyright (C) 2008 Matthew Wild
+-- Copyright (C) 2008 Waqas Hussain
+-- 
+-- This program is free software; you can redistribute it and/or
+-- modify it under the terms of the GNU General Public License
+-- as published by the Free Software Foundation; either version 2
+-- of the License, or (at your option) any later version.
+-- 
+-- This program is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+-- GNU General Public License for more details.
+-- 
+-- You should have received a copy of the GNU General Public License
+-- along with this program; if not, write to the Free Software
+-- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+--
+
+
 
 local format = string.format;
 local send_s2s = require "core.s2smanager".send_to_host;
@@ -8,7 +28,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 +46,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 +62,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;
@@ -64,7 +84,7 @@ add_handler({ "s2sout_unauthed", "s2sout" }, "verify", xmlns_dialback,
                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);