Updated toriptables2.py Refactor

This commit is contained in:
Rupert Edwards 2016-01-04 03:05:44 -05:00
parent 3ddac874f6
commit d1eb99448f
1 changed files with 4 additions and 2 deletions

View File

@ -9,7 +9,7 @@ and traffic including DNS through the tor network.
from __future__ import print_function
from commands import getoutput
from subprocess import call, check_call, CalledProcessError
from os.path import isfile
from os.path import isfile, basename
from os import devnull
from sys import stdout, stderr
from atexit import register
@ -27,12 +27,14 @@ class TorIptables(object):
self.trans_port = "9040" # Tor port
self.tor_config_file = '/etc/tor/torrc'
self.torrc = '''
## Inserted by %s for tor iptables rules set
## Transparently route all traffic thru tor on port %s
VirtualAddrNetwork %s
AutomapHostsOnResolve 1
TransPort %s
DNSPort %s
''' % (self.trans_port, self.virtual_net, self.trans_port, self.local_dnsport)
''' % (basename(__file__), self.trans_port, self.virtual_net,
self.trans_port, self.local_dnsport)
def flush_iptables_rules(self):
call(["iptables", "-F"])