This commit is contained in:
endes 2020-04-19 20:14:21 +01:00
parent 35e8ce60a9
commit 5a4b6be974

View file

@ -34,8 +34,8 @@ def is_valid_public_ipv4(address, allow_localhost: bool = False):
if parsed_ip.is_loopback and allow_localhost:
return True
if any(parsed_ip.version != 4, parsed_ip.is_unspecified, parsed_ip.is_link_local, parsed_ip.is_loopback,
parsed_ip.is_multicast, parsed_ip.is_reserved, parsed_ip.is_private, parsed_ip.is_reserved):
if any((parsed_ip.version != 4, parsed_ip.is_unspecified, parsed_ip.is_link_local, parsed_ip.is_loopback,
parsed_ip.is_multicast, parsed_ip.is_reserved, parsed_ip.is_private, parsed_ip.is_reserved)):
return False
else:
return not any((CARRIER_GRADE_NAT_SUBNET.supernet_of(ipaddress.ip_network(f"{address}/32")),