aboutsummaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
authorGravatar jesopo2019-04-25 17:48:51 +0100
committerGravatar jesopo2019-04-25 17:48:51 +0100
commit1240b154cbd7a2a48f499ac387b054ef0f13e573 (patch)
tree54a7b6046814a765aa3034823c492fbc1fc3afae /src/utils
parentAdd netifaces to requirements (diff)
signature
Support interfaces that don't have AF_INET and/or AF_INET6
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/http.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/utils/http.py b/src/utils/http.py
index 09a47607..2e71792d 100644
--- a/src/utils/http.py
+++ b/src/utils/http.py
@@ -110,8 +110,11 @@ def is_localhost(hostname: str) -> bool:
for interface in netifaces.interfaces():
links = netifaces.ifaddresses(interface)
- for link in links[netifaces.AF_INET]+links[netifaces.AF_INET6]:
+
+ for link in links.get(netifaces.AF_INET, []
+ )+links.get(netifaces.AF_INET6, [])
address = ipaddress.ip_address(link["addr"].split("%", 1)[0])
if address in ips:
return True
+
return False