Mercurial > prosody-hg
comparison plugins/mod_dialback.lua @ 4848:f7a4920aed6b
mod_dialback: Final sweep to get nameprep + error handling in order (hopefully)
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Fri, 11 May 2012 02:04:29 +0100 |
| parents | 7a7cc4d98faf |
| children | 8e3992ae7bf5 |
comparison
equal
deleted
inserted
replaced
| 4847:7a7cc4d98faf | 4848:f7a4920aed6b |
|---|---|
| 63 | 63 |
| 64 if origin.type == "s2sin_unauthed" or origin.type == "s2sin" then | 64 if origin.type == "s2sin_unauthed" or origin.type == "s2sin" then |
| 65 -- he wants to be identified through dialback | 65 -- he wants to be identified through dialback |
| 66 -- We need to check the key with the Authoritative server | 66 -- We need to check the key with the Authoritative server |
| 67 local attr = stanza.attr; | 67 local attr = stanza.attr; |
| 68 local to, from = attr.to, attr.from; | 68 local to, from = nameprep(attr.to), nameprep(attr.from); |
| 69 | |
| 70 origin.hosts[from] = { dialback_key = stanza[1] }; | |
| 71 | 69 |
| 72 if not hosts[to] then | 70 if not hosts[to] then |
| 73 -- Not a host that we serve | 71 -- Not a host that we serve |
| 74 origin.log("info", "%s tried to connect to %s, which we don't serve", from, to); | 72 origin.log("info", "%s tried to connect to %s, which we don't serve", from, to); |
| 75 origin:close("host-unknown"); | 73 origin:close("host-unknown"); |
| 76 return true; | 74 return true; |
| 75 elseif not from then | |
| 76 origin:close("improper-addressing"); | |
| 77 end | 77 end |
| 78 | |
| 79 origin.hosts[from] = { dialback_key = stanza[1] }; | |
| 78 | 80 |
| 79 dialback_requests[from.."/"..origin.streamid] = origin; | 81 dialback_requests[from.."/"..origin.streamid] = origin; |
| 80 | 82 |
| 81 -- COMPAT: ejabberd, gmail and perhaps others do not always set 'to' and 'from' | 83 -- COMPAT: ejabberd, gmail and perhaps others do not always set 'to' and 'from' |
| 82 -- on streams. We fill in the session's to/from here instead. | 84 -- on streams. We fill in the session's to/from here instead. |
| 83 if not origin.from_host then | 85 if not origin.from_host then |
| 84 origin.from_host = nameprep(attr.from); | 86 origin.from_host = from; |
| 85 if not origin.from_host then | |
| 86 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."); | |
| 87 origin:close("invalid-from"); | |
| 88 end | |
| 89 end | 87 end |
| 90 if not origin.to_host then | 88 if not origin.to_host then |
| 91 origin.to_host = nameprep(attr.to); | 89 origin.to_host = nameprep(attr.to); |
| 92 end | 90 end |
| 93 | 91 |
| 94 if not origin.from_host or not origin.to_host then | |
| 95 origin.log("debug", "Improper addressing supplied, no to or from?"); | |
| 96 origin:close("improper-addressing"); | |
| 97 end | |
| 98 | |
| 99 origin.log("debug", "asking %s if key %s belongs to them", from, stanza[1]); | 92 origin.log("debug", "asking %s if key %s belongs to them", from, stanza[1]); |
| 100 module:fire_event("route/remote", { | 93 module:fire_event("route/remote", { |
| 101 from_host = to, to_host = from; | 94 from_host = to, to_host = from; |
| 102 stanza = st.stanza("db:verify", { from = to, to = from, id = origin.streamid }):text(stanza[1]); | 95 stanza = st.stanza("db:verify", { from = to, to = from, id = origin.streamid }):text(stanza[1]); |
| 103 }); | 96 }); |
