# HG changeset patch # User Matthew Wild # Date 1544697326 0 # Node ID 823027110e2912a86862273944dbc7670a02c072 # Parent 6a3060d5e85df51794aee2e46af6521f0fb1edbf mod_muc_ban_ip: Improve logging to use session, and log when a ban is enforced diff -r 6a3060d5e85d -r 823027110e29 mod_muc_ban_ip/mod_muc_ban_ip.lua --- a/mod_muc_ban_ip/mod_muc_ban_ip.lua Tue Dec 11 18:27:40 2018 +0100 +++ b/mod_muc_ban_ip/mod_muc_ban_ip.lua Thu Dec 13 10:35:26 2018 +0000 @@ -19,7 +19,7 @@ ip_bans[ip] = banned_from; end banned_from[from] = true; - module:log("debug", "Banned IP address %s from %s", ip, from); + module:log("debug", "Added ban for IP address %s from %s", ip, from); end local function check_for_incoming_ban(event) @@ -43,15 +43,17 @@ end local function check_for_ban(event) - local ip = event.origin.ip; - local to = jid_bare(event.stanza.attr.to); + local origin, stanza = event.origin, event.stanza; + local ip = origin.ip; + local to = jid_bare(stanza.attr.to); if ip_bans[ip] and ip_bans[ip][to] then - event.origin.send(st.error_reply(event.stanza, "auth", "forbidden") + origin.log("debug", "IP banned: %s is banned from %s", ip, to) + origin.send(st.error_reply(stanza, "auth", "forbidden") :tag("x", { xmlns = xmlns_muc_user }) :tag("status", { code = '301' })); return true; end - module:log("debug", "Not banned: %s from %s", ip, to) + origin.log("debug", "IP not banned: %s from %s", ip, to) end function module.add_host(module)