Comparison

plugins/mod_dialback.lua @ 4837:9f1fb34cd7f8

mod_dialback: make change a bit more wide, encompass to and from and reject with proper addressing when neither are there.
author Marco Cirillo <maranda@lightwitch.org>
date Wed, 09 May 2012 23:09:06 +0000
parent 4836:bda0593d3f73
child 4841:ce793cea9f10
child 4842:88101f652174
comparison
equal deleted inserted replaced
4836:bda0593d3f73 4837:9f1fb34cd7f8
74 return true; 74 return true;
75 end 75 end
76 76
77 dialback_requests[attr.from.."/"..origin.streamid] = origin; 77 dialback_requests[attr.from.."/"..origin.streamid] = origin;
78 78
79 local compat_check;
79 if not origin.from_host then 80 if not origin.from_host then
80 -- Just used for friendlier logging 81 -- Just used for friendlier logging
81 origin.from_host = nameprep(attr.from); 82 origin.from_host = nameprep(attr.from);
82 -- COMPAT: Fix ejabberd chopness by resetting the send function 83 -- COMPAT: Fix server's chopness by not including from
83 if not origin.from_host then 84 compat_check = true;
84 origin.log("debug", "We need to know where to connect but remote server blindly refuses to tell us and to comply to specs, closing connection.");
85 origin:close("invalid-from");
86 else
87 origin.log("debug", "Remote server didn't specify a from attr, resetting session.send now that we know where to knock to.");
88 origin.send = function(stanza) hosts[attr.to].events.fire_event("route/remote", { from_host = origin.to_host, to_host = origin.from_host, stanza = stanza}); end
89 end
90 end 85 end
91 if not origin.to_host then 86 if not origin.to_host then
92 -- Just used for friendlier logging 87 -- Just used for friendlier logging
93 origin.to_host = attr.to; 88 origin.to_host = nameprep(attr.to);
89 -- COMPAT: Fix server's chopness by not including to
90 compat_check = true;
91 end
92
93 if not origin.from_host and not origin.to_host then
94 origin.log("debug", "Improper addressing supplied, no to or from?");
95 origin:close("improper-addressing");
96 end
97 -- COMPAT: reset session.send
98 if compat_check then
99 origin.send = function(stanza) hosts[attr.to].events.fire_event("route/remote", { from_host = origin.to_host, to_host = origin.from_host, stanza = stanza}); end
94 end 100 end
95 101
96 origin.log("debug", "asking %s if key %s belongs to them", attr.from, stanza[1]); 102 origin.log("debug", "asking %s if key %s belongs to them", attr.from, stanza[1]);
97 origin.send(st.stanza("db:verify", { from = attr.to, to = attr.from, id = origin.streamid }):text(stanza[1])); 103 origin.send(st.stanza("db:verify", { from = attr.to, to = attr.from, id = origin.streamid }):text(stanza[1]));
98 return true; 104 return true;