Comparison

plugins/mod_dialback.lua @ 6374:f1dd1716aa9d

mod_dialback: Move d-w-d after to/from validation
author Kim Alvefur <zash@zash.se>
date Mon, 01 Sep 2014 20:20:05 +0200
parent 6306:c6d9e21cd5f2
child 6424:89c42aff8510
comparison
equal deleted inserted replaced
6373:84e7e418c29a 6374:f1dd1716aa9d
80 -- he wants to be identified through dialback 80 -- he wants to be identified through dialback
81 -- We need to check the key with the Authoritative server 81 -- We need to check the key with the Authoritative server
82 local attr = stanza.attr; 82 local attr = stanza.attr;
83 local to, from = nameprep(attr.to), nameprep(attr.from); 83 local to, from = nameprep(attr.to), nameprep(attr.from);
84 84
85 if not hosts[to] then
86 -- Not a host that we serve
87 origin.log("warn", "%s tried to connect to %s, which we don't serve", from, to);
88 origin:close("host-unknown");
89 return true;
90 elseif not from then
91 origin:close("improper-addressing");
92 end
93
85 if dwd and origin.secure then 94 if dwd and origin.secure then
86 if check_cert_status(origin, from) == false then 95 if check_cert_status(origin, from) == false then
87 return 96 return
88 elseif origin.cert_chain_status == "valid" and origin.cert_identity_status == "valid" then 97 elseif origin.cert_chain_status == "valid" and origin.cert_identity_status == "valid" then
89 origin.sends2s(st.stanza("db:result", { to = from, from = to, id = attr.id, type = "valid" })); 98 origin.sends2s(st.stanza("db:result", { to = from, from = to, id = attr.id, type = "valid" }));
90 module:fire_event("s2s-authenticated", { session = origin, host = from }); 99 module:fire_event("s2s-authenticated", { session = origin, host = from });
91 return true; 100 return true;
92 end 101 end
93 end
94
95 if not hosts[to] then
96 -- Not a host that we serve
97 origin.log("warn", "%s tried to connect to %s, which we don't serve", from, to);
98 origin:close("host-unknown");
99 return true;
100 elseif not from then
101 origin:close("improper-addressing");
102 end 102 end
103 103
104 origin.hosts[from] = { dialback_key = stanza[1] }; 104 origin.hosts[from] = { dialback_key = stanza[1] };
105 105
106 dialback_requests[from.."/"..origin.streamid] = origin; 106 dialback_requests[from.."/"..origin.streamid] = origin;