core/stanza_router.lua

branch
s2s
changeset 146
3826ca244eb6
parent 145
fbb3a4ff9cf1
child 147
ccebb2720741
equal deleted inserted replaced
145:fbb3a4ff9cf1 146:3826ca244eb6
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
206 end 216 end
207 end 217 end
208 end 218 end
209 else 219 else
210 -- Remote host 220 -- Remote host
221 log("debug", "sending s2s stanza: %s", tostring(stanza));
222 stanza.attr.xmlns = "jabber:server";
211 send_s2s(origin.host, host, stanza); 223 send_s2s(origin.host, host, stanza);
212 end 224 end
213 stanza.attr.to = to; -- reset 225 stanza.attr.to = to; -- reset
214 end 226 end
215 227

mercurial