From 1f80a8bf444ccaa872468ee48e810a0db66b4eab Mon Sep 17 00:00:00 2001 From: Rupert Edwards Date: Sat, 16 Jul 2016 15:52:28 -0400 Subject: [PATCH] Updated Get public ip address --- toriptables2.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/toriptables2.py b/toriptables2.py index d4d25a8..c310d40 100755 --- a/toriptables2.py +++ b/toriptables2.py @@ -59,14 +59,14 @@ DNSPort %s "[\033[92m+\033[0m] Anonymizer status \033[92m[ON]\033[0m")) print(" {0}".format("[\033[92m*\033[0m] Getting public IP, please wait ...")) try: - try: - my_public_ip = load(urlopen('http://jsonip.com'))['ip'] - except URLError: - my_public_ip = getoutput('wget -qO - v4.ifconfig.co') - print(" {0}".format( - "[\033[92m+\033[0m] Your IP is \033[92m%s\033[0m" % my_public_ip)) - except: - print(" \033[91m[!]\033[0m Can't get public ip address!") + my_public_ip = load(urlopen('http://jsonip.com'))['ip'] + except URLError: + my_public_ip = None + my_public_ip = getoutput('wget -qO - v4.ifconfig.co') + if not my_public_ip: + exit(" \033[91m[!]\033[0m Can't get public ip address!") + print(" {0}".format( + "[\033[92m+\033[0m] Your IP is \033[92m%s\033[0m" % my_public_ip)) except CalledProcessError as err: print("[!] Command failed: %s" % err.cmd)