Software /
code /
prosody
Comparison
plugins/mod_dialback.lua @ 4822:5ef05f32bc42
mod_s2s, s2smanager, mod_dialback: Move addition of session.send() on s2sin to after they are authenticated (thus from mod_s2s to s2smanager). Update mod_dialback to fire route/remote directly, as session.send() is no longer available for s2sin_unauthed. Fixes #291.
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Thu, 10 May 2012 22:59:01 +0100 |
parent | 4761:178f252c31b0 |
child | 4846:3bc3498df0a0 |
comparison
equal
deleted
inserted
replaced
4821:deec69fc33e5 | 4822:5ef05f32bc42 |
---|---|
62 | 62 |
63 if origin.type == "s2sin_unauthed" or origin.type == "s2sin" then | 63 if origin.type == "s2sin_unauthed" or origin.type == "s2sin" then |
64 -- he wants to be identified through dialback | 64 -- he wants to be identified through dialback |
65 -- We need to check the key with the Authoritative server | 65 -- We need to check the key with the Authoritative server |
66 local attr = stanza.attr; | 66 local attr = stanza.attr; |
67 origin.hosts[attr.from] = { dialback_key = stanza[1] }; | 67 local to, from = attr.to, attr.from; |
68 | 68 |
69 if not hosts[attr.to] then | 69 origin.hosts[from] = { dialback_key = stanza[1] }; |
70 | |
71 if not hosts[to] then | |
70 -- Not a host that we serve | 72 -- Not a host that we serve |
71 origin.log("info", "%s tried to connect to %s, which we don't serve", attr.from, attr.to); | 73 origin.log("info", "%s tried to connect to %s, which we don't serve", from, to); |
72 origin:close("host-unknown"); | 74 origin:close("host-unknown"); |
73 return true; | 75 return true; |
74 end | 76 end |
75 | 77 |
76 dialback_requests[attr.from.."/"..origin.streamid] = origin; | 78 dialback_requests[from.."/"..origin.streamid] = origin; |
77 | 79 |
78 if not origin.from_host then | 80 -- COMPAT: ejabberd, gmail and perhaps others do not always set 'to' and 'from' |
79 -- Just used for friendlier logging | 81 -- on streams. We fill in the session's to/from here instead. |
80 origin.from_host = attr.from; | 82 if not origin.from_host then origin.from_host = from; end |
81 end | 83 if not origin.to_host then origin.to_host = to; end |
82 if not origin.to_host then | |
83 -- Just used for friendlier logging | |
84 origin.to_host = attr.to; | |
85 end | |
86 | 84 |
87 origin.log("debug", "asking %s if key %s belongs to them", attr.from, stanza[1]); | 85 origin.log("debug", "asking %s if key %s belongs to them", from, stanza[1]); |
88 origin.send(st.stanza("db:verify", { from = attr.to, to = attr.from, id = origin.streamid }):text(stanza[1])); | 86 module:fire_event("route/remote", { |
87 from_host = to, to_host = from; | |
88 stanza = st.stanza("db:verify", { from = to, to = from, id = origin.streamid }):text(stanza[1]); | |
89 }); | |
89 return true; | 90 return true; |
90 end | 91 end |
91 end); | 92 end); |
92 | 93 |
93 module:hook("stanza/jabber:server:dialback:verify", function(event) | 94 module:hook("stanza/jabber:server:dialback:verify", function(event) |