in iptables.py [0:0]
def is_blocked(self, ip: typing.Union[Entry, str, netaddr.IPNetwork]) -> typing.Optional[Entry]:
"""Finds out if an IP address or block is contained within a block in this chain. Returns the matching block
rule if any"""
if isinstance(ip, Entry):
if ip in self.items:
return ip
return
if isinstance(ip, str):
ip = netaddr.IPNetwork(ip)
for entry in self.items:
# Either the block is contained within a rule, or the rule is contained within the block...who knows!
if ip in entry.as_net or entry.as_net in ip:
return entry