Mercurial > prosody-modules
comparison mod_muc_ban_ip/mod_muc_ban_ip.lua @ 3995:4c9805f29f2d
mod_muc_ban_ip: log fallback to module
author | Georg Lukas <georg@op-co.de> |
---|---|
date | Thu, 15 Aug 2019 09:26:02 +0200 |
parents | 823027110e29 |
children | 71498f484c22 |
comparison
equal
deleted
inserted
replaced
3994:5a3dfb970888 | 3995:4c9805f29f2d |
---|---|
45 local function check_for_ban(event) | 45 local function check_for_ban(event) |
46 local origin, stanza = event.origin, event.stanza; | 46 local origin, stanza = event.origin, event.stanza; |
47 local ip = origin.ip; | 47 local ip = origin.ip; |
48 local to = jid_bare(stanza.attr.to); | 48 local to = jid_bare(stanza.attr.to); |
49 if ip_bans[ip] and ip_bans[ip][to] then | 49 if ip_bans[ip] and ip_bans[ip][to] then |
50 origin.log("debug", "IP banned: %s is banned from %s", ip, to) | 50 (origin.log or module._log)("debug", "IP banned: %s is banned from %s", ip, to) |
51 origin.send(st.error_reply(stanza, "auth", "forbidden") | 51 origin.send(st.error_reply(stanza, "auth", "forbidden") |
52 :tag("x", { xmlns = xmlns_muc_user }) | 52 :tag("x", { xmlns = xmlns_muc_user }) |
53 :tag("status", { code = '301' })); | 53 :tag("status", { code = '301' })); |
54 return true; | 54 return true; |
55 end | 55 end |
56 origin.log("debug", "IP not banned: %s from %s", ip, to) | 56 (origin.log or module._log)("debug", "IP not banned: %s from %s", ip, to) |
57 end | 57 end |
58 | 58 |
59 function module.add_host(module) | 59 function module.add_host(module) |
60 module:hook("presence/full", check_for_incoming_ban, 100); | 60 module:hook("presence/full", check_for_incoming_ban, 100); |
61 module:hook("pre-presence/full", check_for_ban, 100); | 61 module:hook("pre-presence/full", check_for_ban, 100); |