Mercurial > prosody-modules
diff mod_s2s_auth_dane/mod_s2s_auth_dane.lua @ 1367:103d685e2153
mod_s2s_auth_dane: Pause s2sin while doing SRV and TLSA lookups, fixes race condition (Can haz util.async plz)
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 20 Mar 2014 15:31:15 +0100 |
parents | 920ac9a8480b |
children | 5724008bbdb1 |
line wrap: on
line diff
--- a/mod_s2s_auth_dane/mod_s2s_auth_dane.lua Wed Mar 19 23:17:55 2014 +0100 +++ b/mod_s2s_auth_dane/mod_s2s_auth_dane.lua Thu Mar 20 15:31:15 2014 +0100 @@ -108,8 +108,17 @@ function module.add_host(module) module:hook("s2s-stream-features", function(event) -- dane_lookup(origin, origin.from_host); - dane_lookup(event.origin); - end, 1); + local host_session = event.origin; + host_session.log("debug", "Pausing connection until DANE lookup is completed"); + host_session.conn:pause() + local function resume() + module:log("eebug", "Resuming connection"); + host_session.conn:resume() + end + if not dane_lookup(host_session, resume) then + resume(); + end + end, 10); module:hook("s2s-authenticated", function(event) local session = event.session;