aboutsummaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
authorGravatar jesopo2019-09-30 15:15:20 +0100
committerGravatar jesopo2019-09-30 15:15:20 +0100
commitf306213cb8c622d65315f718ef2abb250d5093eb (patch)
tree64279996d6da87efdd89337c7d89c9a6a84c3901 /src/utils
parentuse ipaddress is_loopback etc to do better forbidden ranges (diff)
signature
'is_localhost()' -> 'host_permitted()'
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/http.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/utils/http.py b/src/utils/http.py
index 00066033..4df01dfc 100644
--- a/src/utils/http.py
+++ b/src/utils/http.py
@@ -287,7 +287,7 @@ def is_ip(addr: str) -> bool:
return False
return True
-def is_localhost(hostname: str) -> bool:
+def host_permitted(hostname: str) -> bool:
if is_ip(hostname):
ips = [ipaddress.ip_address(hostname)]
else:
@@ -300,7 +300,7 @@ def is_localhost(hostname: str) -> bool:
)+links.get(netifaces.AF_INET6, []):
address = ipaddress.ip_address(link["addr"].split("%", 1)[0])
if address in ips:
- return True
+ return False
for ip in ips:
if ip.version == 6 and ip.ipv4_mapped:
ip = ip.ipv4_mapped
@@ -309,6 +309,6 @@ def is_localhost(hostname: str) -> bool:
ip.is_link_local or
ip.is_multicast or
ip.is_private):
- return True
+ return False
- return False
+ return True