Mercurial > prosody-modules
diff mod_muc_ban_ip/mod_muc_ban_ip.lua @ 3403:823027110e29
mod_muc_ban_ip: Improve logging to use session, and log when a ban is enforced
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Thu, 13 Dec 2018 10:35:26 +0000 |
parents | 933403ee07ec |
children | 4c9805f29f2d |
line wrap: on
line diff
--- 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)