diff options
| author | 2019-04-25 17:48:51 +0100 | |
|---|---|---|
| committer | 2019-04-25 17:48:51 +0100 | |
| commit | 1240b154cbd7a2a48f499ac387b054ef0f13e573 (patch) | |
| tree | 54a7b6046814a765aa3034823c492fbc1fc3afae /src/utils | |
| parent | Add 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.py | 5 |
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 |
