17 -- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
17 -- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
18 -- |
18 -- |
19 |
19 |
20 |
20 |
21 |
21 |
22 local format = string.format; |
|
23 local send_s2s = require "core.s2smanager".send_to_host; |
22 local send_s2s = require "core.s2smanager".send_to_host; |
24 local s2s_make_authenticated = require "core.s2smanager".make_authenticated; |
23 local s2s_make_authenticated = require "core.s2smanager".make_authenticated; |
25 local s2s_verify_dialback = require "core.s2smanager".verify_dialback; |
24 local s2s_verify_dialback = require "core.s2smanager".verify_dialback; |
26 |
25 |
27 local st = require "util.stanza"; |
26 local st = require "util.stanza"; |
43 else |
42 else |
44 type = "invalid" |
43 type = "invalid" |
45 log("warn", "Asked to verify a dialback key that was incorrect. An imposter is claiming to be %s?", attr.to); |
44 log("warn", "Asked to verify a dialback key that was incorrect. An imposter is claiming to be %s?", attr.to); |
46 end |
45 end |
47 log("debug", "verified dialback key... it is %s", type); |
46 log("debug", "verified dialback key... it is %s", type); |
48 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])); |
47 origin.sends2s(st.stanza("db:verify", { from = attr.to, to = attr.from, id = attr.id, type = type }):text(stanza[1])); |
49 end); |
48 end); |
50 |
49 |
51 module:add_handler("s2sin_unauthed", "result", xmlns_dialback, |
50 module:add_handler("s2sin_unauthed", "result", xmlns_dialback, |
52 function (origin, stanza) |
51 function (origin, stanza) |
53 -- he wants to be identified through dialback |
52 -- he wants to be identified through dialback |
77 valid = "invalid"; |
76 valid = "invalid"; |
78 end |
77 end |
79 if not origin.dialback_verifying.sends2s then |
78 if not origin.dialback_verifying.sends2s then |
80 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+$")); |
79 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+$")); |
81 else |
80 else |
82 origin.dialback_verifying.sends2s(format("<db:result from='%s' to='%s' id='%s' type='%s'>%s</db:result>", |
81 origin.dialback_verifying.sends2s( |
83 attr.to, attr.from, attr.id, valid, origin.dialback_verifying.dialback_key)); |
82 st.stanza("db:result", { from = attr.to, to = attr.from, id = attr.id, type = valid }) |
|
83 :text(origin.dialback_verifying.dialback_key)); |
84 end |
84 end |
85 end |
85 end |
86 end); |
86 end); |
87 |
87 |
88 module:add_handler({ "s2sout_unauthed", "s2sout" }, "result", xmlns_dialback, |
88 module:add_handler({ "s2sout_unauthed", "s2sout" }, "result", xmlns_dialback, |