From 242575d7aabdddc29a0a2a78bd4e5a154c0ada81 Mon Sep 17 00:00:00 2001 From: timothymiller Date: Sun, 4 Oct 2020 13:54:01 -0400 Subject: [PATCH] =?UTF-8?q?=E2=9B=8F=EF=B8=8F=20Fix:=20Gracefully=20handle?= =?UTF-8?q?s=20all=20IPv4=20or=20IPv6=20connectivity=20scenarios?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cloudflare-ddns.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/cloudflare-ddns.py b/cloudflare-ddns.py index 2ea1095..6270d04 100755 --- a/cloudflare-ddns.py +++ b/cloudflare-ddns.py @@ -11,8 +11,16 @@ with open(PATH + "config.json") as config_file: config = json.loads(config_file.read()) def getIPs(): - a = requests.get("https://dns.timknowsbest.com/api/ipv4").text - aaaa = requests.get("https://api6.ipify.org?format=json").json().get("ip") + a = "" + aaaa = "" + try: + a = requests.get("https://dns.timknowsbest.com/api/ipv4").text + except Exception: + print("Warning: IPv4 not detected.") + try: + aaaa = requests.get("https://api6.ipify.org?format=json").json().get("ip") + except Exception: + print("Warning: IPv6 not detected.") ips = [] if(a.find(".") > -1):