Software / code / prosody
Comparison
plugins/mod_dialback.lua @ 4316:2478698bdc52
Merge 0.8->trunk
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Tue, 07 Jun 2011 01:29:34 +0100 |
| parent | 4264:fa36e749749c |
| parent | 4314:1e1110840965 |
| child | 4567:24617f360200 |
comparison
equal
deleted
inserted
replaced
| 4307:332fc256c76e | 4316:2478698bdc52 |
|---|---|
| 58 origin.log("info", "%s tried to connect to %s, which we don't serve", attr.from, attr.to); | 58 origin.log("info", "%s tried to connect to %s, which we don't serve", attr.from, attr.to); |
| 59 origin:close("host-unknown"); | 59 origin:close("host-unknown"); |
| 60 return true; | 60 return true; |
| 61 end | 61 end |
| 62 | 62 |
| 63 dialback_requests[attr.from] = origin; | 63 dialback_requests[attr.from.."/"..origin.streamid] = origin; |
| 64 | 64 |
| 65 if not origin.from_host then | 65 if not origin.from_host then |
| 66 -- Just used for friendlier logging | 66 -- Just used for friendlier logging |
| 67 origin.from_host = attr.from; | 67 origin.from_host = attr.from; |
| 68 end | 68 end |
| 81 module:hook("stanza/jabber:server:dialback:verify", function(event) | 81 module:hook("stanza/jabber:server:dialback:verify", function(event) |
| 82 local origin, stanza = event.origin, event.stanza; | 82 local origin, stanza = event.origin, event.stanza; |
| 83 | 83 |
| 84 if origin.type == "s2sout_unauthed" or origin.type == "s2sout" then | 84 if origin.type == "s2sout_unauthed" or origin.type == "s2sout" then |
| 85 local attr = stanza.attr; | 85 local attr = stanza.attr; |
| 86 local dialback_verifying = dialback_requests[attr.from]; | 86 local dialback_verifying = dialback_requests[attr.from.."/"..(attr.id or "")]; |
| 87 if dialback_verifying then | 87 if dialback_verifying and attr.from == origin.to_host then |
| 88 local valid; | 88 local valid; |
| 89 if attr.type == "valid" then | 89 if attr.type == "valid" then |
| 90 s2s_make_authenticated(dialback_verifying, attr.from); | 90 s2s_make_authenticated(dialback_verifying, attr.from); |
| 91 valid = "valid"; | 91 valid = "valid"; |
| 92 else | 92 else |
| 99 else | 99 else |
| 100 dialback_verifying.sends2s( | 100 dialback_verifying.sends2s( |
| 101 st.stanza("db:result", { from = attr.to, to = attr.from, id = attr.id, type = valid }) | 101 st.stanza("db:result", { from = attr.to, to = attr.from, id = attr.id, type = valid }) |
| 102 :text(dialback_verifying.hosts[attr.from].dialback_key)); | 102 :text(dialback_verifying.hosts[attr.from].dialback_key)); |
| 103 end | 103 end |
| 104 dialback_requests[attr.from] = nil; | 104 dialback_requests[attr.from.."/"..(attr.id or "")] = nil; |
| 105 end | 105 end |
| 106 return true; | 106 return true; |
| 107 end | 107 end |
| 108 end); | 108 end); |
| 109 | 109 |