core/stanza_router.lua

changeset 190
1e993b7deae7
parent 187
2e16e5077d8f
child 191
e64c8a44060f
equal deleted inserted replaced
189:3f0e3a07b491 190:1e993b7deae7
21 21
22 local jid_split = require "util.jid".split; 22 local jid_split = require "util.jid".split;
23 local print = print; 23 local print = print;
24 24
25 function core_process_stanza(origin, stanza) 25 function core_process_stanza(origin, stanza)
26 log("debug", "Received: "..tostring(stanza)) 26 log("debug", "Received["..origin.type.."]: "..tostring(stanza))
27 -- TODO verify validity of stanza (as well as JID validity) 27 -- TODO verify validity of stanza (as well as JID validity)
28 if stanza.name == "iq" and not(#stanza.tags == 1 and stanza.tags[1].attr.xmlns) then 28 if stanza.name == "iq" and not(#stanza.tags == 1 and stanza.tags[1].attr.xmlns) then
29 if stanza.attr.type == "set" or stanza.attr.type == "get" then 29 if stanza.attr.type == "set" or stanza.attr.type == "get" then
30 error("Invalid IQ"); 30 error("Invalid IQ");
31 elseif #stanza.tags > 1 and not(stanza.attr.type == "error" or stanza.attr.type == "result") then 31 elseif #stanza.tags > 1 and not(stanza.attr.type == "error" or stanza.attr.type == "result") then
135 -- We need to check the key with the Authoritative server 135 -- We need to check the key with the Authoritative server
136 local attr = stanza.attr; 136 local attr = stanza.attr;
137 origin.from_host = attr.from; 137 origin.from_host = attr.from;
138 origin.to_host = attr.to; 138 origin.to_host = attr.to;
139 origin.dialback_key = stanza[1]; 139 origin.dialback_key = stanza[1];
140 log("debug", "asking %s if key %s belongs to them", attr.from, stanza[1]); 140 log("debug", "asking %s if key %s belongs to them", origin.from_host, origin.dialback_key);
141 send_s2s(attr.to, attr.from, format("<db:verify from='%s' to='%s' id='%s'>%s</db:verify>", attr.to, attr.from, origin.streamid, stanza[1])); 141 send_s2s(origin.to_host, origin.from_host, format("<db:verify from='%s' to='%s' id='%s'>%s</db:verify>", origin.to_host, origin.from_host, origin.streamid, origin.dialback_key));
142 hosts[attr.from].dialback_verifying = origin; 142 hosts[origin.from_host].dialback_verifying = origin;
143 end 143 end
144 end 144 end
145 elseif origin.type == "s2sout_unauthed" or origin.type == "s2sout" then 145 elseif origin.type == "s2sout_unauthed" or origin.type == "s2sout" then
146 if stanza.attr.xmlns == "jabber:server:dialback" then 146 if stanza.attr.xmlns == "jabber:server:dialback" then
147 if stanza.name == "result" then 147 if stanza.name == "result" then

mercurial