⛏️ Fix: Gracefully handles all IPv4 or IPv6 connectivity scenarios
This commit is contained in:
parent
2ad3d6b564
commit
242575d7aa
@ -11,8 +11,16 @@ with open(PATH + "config.json") as config_file:
|
|||||||
config = json.loads(config_file.read())
|
config = json.loads(config_file.read())
|
||||||
|
|
||||||
def getIPs():
|
def getIPs():
|
||||||
a = requests.get("https://dns.timknowsbest.com/api/ipv4").text
|
a = ""
|
||||||
aaaa = requests.get("https://api6.ipify.org?format=json").json().get("ip")
|
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 = []
|
ips = []
|
||||||
|
|
||||||
if(a.find(".") > -1):
|
if(a.find(".") > -1):
|
||||||
|
|||||||
Reference in New Issue
Block a user