Skip to content

Commit

Permalink
Added Get public Ip address on load
Browse files Browse the repository at this point in the history
  • Loading branch information
ruped24 committed Feb 20, 2016
1 parent 46df77a commit 417be77
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions toriptables2.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from atexit import register
from argparse import ArgumentParser
from json import load
from urllib2 import urlopen
from urllib2 import urlopen, URLError


class TorIptables(object):
Expand Down Expand Up @@ -57,9 +57,13 @@ def restart_tor():
print(" {0}".format(
"[\033[92m+\033[0m] Anonymizer status \033[92m[ON]\033[0m"))
print(" {0}".format("[\033[92m*\033[0m] Getting public IP, please wait ..."))
my_public_ip = load(urlopen('http://jsonip.com'))['ip']
print(" {0}".format(
"[\033[92m+\033[0m] Your IP is \033[92m%s\033[0m" % my_public_ip))
try:
my_public_ip = load(urlopen('http://jsonip.com'))['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:
print("[!] Command failed: %s" % err.cmd)

Expand Down

0 comments on commit 417be77

Please sign in to comment.