# HG changeset patch # User Matthew Wild # Date 1600088327 -3600 # Node ID 82482e7e92cb4007507c81c410d563e11fcaefb2 # Parent a1c6eea971ce9be10826226789b22a2773aa87ee mod_register_dnsbl: Handle missing session in user-registering event (thanks meaz) diff -r a1c6eea971ce -r 82482e7e92cb mod_register_dnsbl/mod_register_dnsbl.lua --- a/mod_register_dnsbl/mod_register_dnsbl.lua Mon Sep 14 13:57:59 2020 +0100 +++ b/mod_register_dnsbl/mod_register_dnsbl.lua Mon Sep 14 13:58:47 2020 +0100 @@ -18,21 +18,22 @@ module:hook("user-registering", function (event) local session, ip = event.session, event.ip; + local log = (session and session.log) or module._log; if not ip then - session.log("debug", "Unable to check DNSBL when IP is unknown"); + log("debug", "Unable to check DNSBL when IP is unknown"); return; end local rbl_ip, err = reverse(ip, rbl); if not rbl_ip then - session.log("debug", "Unable to check DNSBL for ip %s: %s", ip, err); + log("debug", "Unable to check DNSBL for ip %s: %s", ip, err); return; end local wait, done = async.waiter(); adns.lookup(function (reply) if reply and reply[1] and reply[1].a then - session.log("debug", "DNSBL response: %s IN A %s", rbl_ip, reply[1].a); - session.log("info", "Blocking %s from registering %s (dnsbl hit)", ip, event.username); + log("debug", "DNSBL response: %s IN A %s", rbl_ip, reply[1].a); + log("info", "Blocking %s from registering %s (dnsbl hit)", ip, event.username); event.allowed = false; event.reason = "Blocked by DNSBL"; end