diff options
author | Volker Hoffmann <volker@cheleb.net> | 2017-07-14 20:24:02 +0200 |
---|---|---|
committer | Volker Hoffmann <volker@cheleb.net> | 2017-07-14 20:24:02 +0200 |
commit | b5c264b0aaa1b0cb9ae058e31fb03f37b6d463c6 (patch) | |
tree | 37cede579eccc36bc4c5719dabb936201f1553e3 | |
parent | e9b9e87bcb757cd58c28ea2b7184e0180e570c95 (diff) |
fix: access icanhazip.com by hostname
The site is behind Cloudflare and has disabled access by IP (which we
had previously used to get around the chance of getting an IPv6 instead
of an IPv4 address back).
-rw-r--r-- | Common/net.py | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/Common/net.py b/Common/net.py index 126bb5c..1f7f8a6 100644 --- a/Common/net.py +++ b/Common/net.py @@ -3,7 +3,6 @@ Networking Stuff. """ import requests -import socket def is_vpn_connected(): @@ -17,8 +16,8 @@ def is_vpn_connected(): # List of public IPs associated with VPN nodes. vpn_list = load_vpn_list() - # Resolve using socket to avoid getting an IPv6 address - r = requests.get("http://%s" % socket.gethostbyname('icanhazip.com')) + # This may fail if we have IPv6 running (then we get an IPv6 address) + r = requests.get('http://icanhazip.com') ip = r.text.split()[0] if ip in vpn_list: |