11 local send = require "core.sessionmanager".send_to_session; |
11 local send = require "core.sessionmanager".send_to_session; |
12 local send_s2s = require "core.s2smanager".send_to_host; |
12 local send_s2s = require "core.s2smanager".send_to_host; |
13 local user_exists = require "core.usermanager".user_exists; |
13 local user_exists = require "core.usermanager".user_exists; |
14 |
14 |
15 local s2s_verify_dialback = require "core.s2smanager".verify_dialback; |
15 local s2s_verify_dialback = require "core.s2smanager".verify_dialback; |
|
16 local s2s_make_authenticated = require "core.s2smanager".make_authenticated; |
16 local format = string.format; |
17 local format = string.format; |
17 local tostring = tostring; |
18 local tostring = tostring; |
18 |
19 |
19 local jid_split = require "util.jid".split; |
20 local jid_split = require "util.jid".split; |
20 local print = print; |
21 local print = print; |
106 local type = "invalid"; |
107 local type = "invalid"; |
107 if s2s_verify_dialback(attr.id, attr.from, attr.to, stanza[1]) then |
108 if s2s_verify_dialback(attr.id, attr.from, attr.to, stanza[1]) then |
108 type = "valid" |
109 type = "valid" |
109 end |
110 end |
110 origin.send(format("<db:verify from='%s' to='%s' id='%s' type='%s'>%s</db:verify>", attr.to, attr.from, attr.id, type, stanza[1])); |
111 origin.send(format("<db:verify from='%s' to='%s' id='%s' type='%s'>%s</db:verify>", attr.to, attr.from, attr.id, type, stanza[1])); |
|
112 end |
|
113 elseif origin.type == "s2sout_unauthed" then |
|
114 if stanza.name == "result" and stanza.attr.xmlns == "jabber:server:dialback" then |
|
115 if stanza.attr.type == "valid" then |
|
116 s2s_make_authenticated(origin); |
|
117 else |
|
118 -- FIXME |
|
119 error("dialback failed!"); |
|
120 end |
111 end |
121 end |
112 else |
122 else |
113 log("warn", "Unhandled origin: %s", origin.type); |
123 log("warn", "Unhandled origin: %s", origin.type); |
114 end |
124 end |
115 end |
125 end |