ip bans: allow full bans to overlap partial bans.

Allow full banning an IP that is part of a subnet that has already been
partially banned.
This commit is contained in:
evazion
2021-03-23 00:34:35 -05:00
parent d906de8192
commit 41e0cad458
2 changed files with 8 additions and 1 deletions

View File

@@ -71,7 +71,7 @@ class IpBan < ApplicationRecord
errors.add(:ip_addr, "may not have a subnet bigger than /64")
elsif partial_ban? && ip_addr.ipv6? && ip_addr.prefix < 20
errors.add(:ip_addr, "may not have a subnet bigger than /20")
elsif new_record? && IpBan.active.ip_matches(subnetted_ip).exists?
elsif new_record? && IpBan.active.where(category: category).ip_matches(subnetted_ip).exists?
errors.add(:ip_addr, "is already banned")
end
end