Software /
code /
prosody-modules
Changeset
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 | 3402:6a3060d5e85d |
children | 3404:6444fb5dbb51 |
files | mod_muc_ban_ip/mod_muc_ban_ip.lua |
diffstat | 1 files changed, 7 insertions(+), 5 deletions(-) [+] |
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)