Added Get public Ip address on load

This commit is contained in:
Rupert Edwards 2016-02-19 19:40:16 -05:00
parent 46df77ade7
commit 417be77eab

View file

@ -16,7 +16,7 @@ from sys import stdout, stderr
from atexit import register from atexit import register
from argparse import ArgumentParser from argparse import ArgumentParser
from json import load from json import load
from urllib2 import urlopen from urllib2 import urlopen, URLError
class TorIptables(object): class TorIptables(object):
@ -57,9 +57,13 @@ DNSPort %s
print(" {0}".format( print(" {0}".format(
"[\033[92m+\033[0m] Anonymizer status \033[92m[ON]\033[0m")) "[\033[92m+\033[0m] Anonymizer status \033[92m[ON]\033[0m"))
print(" {0}".format("[\033[92m*\033[0m] Getting public IP, please wait ...")) print(" {0}".format("[\033[92m*\033[0m] Getting public IP, please wait ..."))
my_public_ip = load(urlopen('http://jsonip.com'))['ip'] try:
print(" {0}".format( my_public_ip = load(urlopen('http://jsonip.com'))['ip']
"[\033[92m+\033[0m] Your IP is \033[92m%s\033[0m" % my_public_ip)) except URLError:
print(" \033[91m[!]\033[0m Can't get public ip address!")
else:
print(" {0}".format(
"[\033[92m+\033[0m] Your IP is \033[92m%s\033[0m" % my_public_ip))
except CalledProcessError as err: except CalledProcessError as err:
print("[!] Command failed: %s" % err.cmd) print("[!] Command failed: %s" % err.cmd)