def contains(self, ip_address):
"Try to match a candidate ip_address and see whether it was in the list of allowed cidrs"
ip_address = netaddr.IPNetwork(ip_address)
result = False
for cidr in self.cidr:
net = netaddr.IPNetwork(cidr)
if ip_address in net:
result = True
break
if self.invert:
return not result
return result
# Test program
评论列表
文章目录