Black
This commit is contained in:
parent
da05dfe708
commit
4de97abc3a
2676 changed files with 163166 additions and 140084 deletions
|
@ -3,20 +3,16 @@ from ipaddress import IPv4Address, IPv6Address, ip_address, ip_network
|
|||
from typing import Union
|
||||
|
||||
# IP addresses of loopback interfaces
|
||||
LOCAL_IPS = (
|
||||
ip_address('127.0.0.1'),
|
||||
ip_address('::1'),
|
||||
)
|
||||
LOCAL_IPS = (ip_address("127.0.0.1"), ip_address("::1"))
|
||||
|
||||
# RFC1918 - Address allocation for Private Internets
|
||||
LOCAL_NETWORKS = (
|
||||
ip_network('10.0.0.0/8'),
|
||||
ip_network('172.16.0.0/12'),
|
||||
ip_network('192.168.0.0/16'),
|
||||
ip_network("10.0.0.0/8"),
|
||||
ip_network("172.16.0.0/12"),
|
||||
ip_network("192.168.0.0/16"),
|
||||
)
|
||||
|
||||
|
||||
def is_local(address: Union[IPv4Address, IPv6Address]) -> bool:
|
||||
"""Check if an address is local."""
|
||||
return address in LOCAL_IPS or \
|
||||
any(address in network for network in LOCAL_NETWORKS)
|
||||
return address in LOCAL_IPS or any(address in network for network in LOCAL_NETWORKS)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue