Software /
code /
prosody-modules
Changeset
6130:5a0e47ad7d6b
mod_anti_spam: Gracefully handle failure to parse CIDR in IP RTBL
This should prevent a traceback in case the IP address in the RTBL cannot be
parsed (either due to a malformed address being published, or due to a bug in
our parsing code).
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Wed, 01 Jan 2025 11:48:19 +0000 |
parents | 6129:64b4ede37da1 |
children | 6131:f80db102fdb1 |
files | mod_anti_spam/mod_anti_spam.lua |
diffstat | 1 files changed, 10 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/mod_anti_spam/mod_anti_spam.lua Wed Jan 01 09:57:31 2025 +0000 +++ b/mod_anti_spam/mod_anti_spam.lua Wed Jan 01 11:48:19 2025 +0000 @@ -125,10 +125,18 @@ }); new_rtbl_subscription(rtbl_service_jid, "spam_source_ips", { added = function (item) - spam_source_ips:add_subnet(ip.parse_cidr(item)); + local subnet_ip, subnet_bits = ip.parse_cidr(item); + if not subnet_ip then + return; + end + spam_source_ips:add_subnet(subnet_ip, subnet_bits); end; removed = function (item) - spam_source_ips:remove_subnet(ip.parse_cidr(item)); + local subnet_ip, subnet_bits = ip.parse_cidr(item); + if not subnet_ip then + return; + end + spam_source_ips:remove_subnet(subnet_ip, subnet_bits); end; }); new_rtbl_subscription(rtbl_service_jid, "spam_source_jids_sha256", {