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 19, 2016
1 parent 48f3130 commit 46df77a
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions toriptables2.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
from sys import stdout, stderr
from atexit import register
from argparse import ArgumentParser
from json import load
from urllib2 import urlopen


class TorIptables(object):
Expand Down Expand Up @@ -50,12 +52,16 @@ def restart_tor():
fnull = open(devnull, 'w')
try:
tor_restart = check_call(["service", "tor", "restart"],
stdout=fnull, stderr=fnull)
stdout=fnull, stderr=fnull)
if tor_restart is 0:
print(" {0}".format(
"[\033[92m+\033[0m] Anonymizer \033[92mON\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 ..."))
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))
except CalledProcessError as err:
print("\n[!] Command failed: %s" % err.cmd)
print("[!] Command failed: %s" % err.cmd)

call(["iptables", "-t", "nat", "-A", "OUTPUT", "-m", "owner", "--uid-owner",
"%s" % self.tor_uid, "-j", "RETURN"])
Expand Down Expand Up @@ -105,7 +111,8 @@ def restart_tor():
load_tables.load_iptables_rules()
elif args.flush:
load_tables.flush_iptables_rules()
print(" {0}".format("[\033[93m!\033[0m] Anonymizer \033[91mOFF\033[0m"))
print(" {0}".format(
"[\033[93m!\033[0m] Anonymizer status \033[91m[OFF]\033[0m"))
else:
parser.print_help()
except Exception as err:
Expand Down

0 comments on commit 46df77a

Please sign in to comment.