Comparison

plugins/mod_dialback.lua @ 11526:15a3db955ad3

s2s et al.: Add counters for connection state transitions
author Jonas Schäfer <jonas@wielicki.name>
date Wed, 21 Apr 2021 17:11:58 +0200
parent 10380:18685a5e362e
child 11560:3bbb1af92514
comparison
equal deleted inserted replaced
11525:5f99fcc43938 11526:15a3db955ad3
113 if dwd and origin.secure then 113 if dwd and origin.secure then
114 if check_cert_status(origin, from) == false then 114 if check_cert_status(origin, from) == false then
115 return 115 return
116 elseif origin.cert_chain_status == "valid" and origin.cert_identity_status == "valid" then 116 elseif origin.cert_chain_status == "valid" and origin.cert_identity_status == "valid" then
117 origin.sends2s(st.stanza("db:result", { to = from, from = to, id = attr.id, type = "valid" })); 117 origin.sends2s(st.stanza("db:result", { to = from, from = to, id = attr.id, type = "valid" }));
118 module:fire_event("s2s-authenticated", { session = origin, host = from }); 118 module:fire_event("s2s-authenticated", { session = origin, host = from, mechanism = "dialback" });
119 return true; 119 return true;
120 end 120 end
121 end 121 end
122 122
123 origin.hosts[from] = { dialback_key = stanza[1] }; 123 origin.hosts[from] = { dialback_key = stanza[1] };
149 local attr = stanza.attr; 149 local attr = stanza.attr;
150 local dialback_verifying = dialback_requests[attr.from.."/"..(attr.id or "")]; 150 local dialback_verifying = dialback_requests[attr.from.."/"..(attr.id or "")];
151 if dialback_verifying and attr.from == origin.to_host then 151 if dialback_verifying and attr.from == origin.to_host then
152 local valid; 152 local valid;
153 if attr.type == "valid" then 153 if attr.type == "valid" then
154 module:fire_event("s2s-authenticated", { session = dialback_verifying, host = attr.from }); 154 module:fire_event("s2s-authenticated", { session = dialback_verifying, host = attr.from, mechanism = "dialback" });
155 valid = "valid"; 155 valid = "valid";
156 else 156 else
157 -- Warn the original connection that is was not verified successfully 157 -- Warn the original connection that is was not verified successfully
158 log("warn", "authoritative server for %s denied the key", attr.from or "(unknown)"); 158 log("warn", "authoritative server for %s denied the key", attr.from or "(unknown)");
159 valid = "invalid"; 159 valid = "invalid";
186 -- This isn't right 186 -- This isn't right
187 origin:close("invalid-id"); 187 origin:close("invalid-id");
188 return true; 188 return true;
189 end 189 end
190 if stanza.attr.type == "valid" then 190 if stanza.attr.type == "valid" then
191 module:fire_event("s2s-authenticated", { session = origin, host = attr.from }); 191 module:fire_event("s2s-authenticated", { session = origin, host = attr.from, mechanism = "dialback" });
192 else 192 else
193 origin:close("not-authorized", "dialback authentication failed"); 193 origin:close("not-authorized", "dialback authentication failed");
194 end 194 end
195 return true; 195 return true;
196 end 196 end