Skip to content

Commit

Permalink
Update toriptables2.py
Browse files Browse the repository at this point in the history
  • Loading branch information
ruped24 authored Jul 16, 2016
1 parent 1f80a8b commit 76f44f5
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions toriptables2.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#! /usr/bin/env python
#! /usr/bin/env python
# Written by Rupe version 2
#
"""
Expand All @@ -17,6 +16,7 @@
from atexit import register
from argparse import ArgumentParser
from json import load
from pynotify import init, Notification
from urllib2 import urlopen, URLError


Expand Down Expand Up @@ -61,12 +61,14 @@ def restart_tor():
try:
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))
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))
init('toriptables2')
my_ip = Notification("Your public IP address is %s" % my_public_ip)
my_ip.show()

except CalledProcessError as err:
print("[!] Command failed: %s" % err.cmd)

Expand Down Expand Up @@ -120,6 +122,14 @@ def restart_tor():
load_tables.flush_iptables_rules()
print(" {0}".format(
"[\033[93m!\033[0m] Anonymizer status \033[91m[OFF]\033[0m"))
try:
my_real_ip = load(urlopen('http://jsonip.com'))['ip']
except URLError:
pass
else:
init('toriptables2')
my_own_ip = Notification("Your public IP address is %s" % my_real_ip)
my_own_ip.show()
else:
parser.print_help()
except Exception as err:
Expand Down

0 comments on commit 76f44f5

Please sign in to comment.