Skip to content

Commit

Permalink
Auto disable IPv6 #7
Browse files Browse the repository at this point in the history
  • Loading branch information
bissito committed Feb 17, 2022
1 parent 4eb42dd commit aef55bf
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions torall.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,22 @@ def check_root():
sys.exit(0)


def backup_sysctl():
print(MARGIN + clr.BLUE + 'Backing up sysctl...' + clr.END)
os.system('sysctl -a >/var/lib/torall/sysctl.conf.bak')


def restore_sysctl():
print(MARGIN + clr.BLUE + 'Restoring sysctl...' + clr.END)
os.system('sysctl -p /var/lib/torall/sysctl.conf.bak &>"/dev/null"')


def disable_ipv6():
print(MARGIN + clr.BLUE + 'Disabling IPv6...' + clr.END)
os.system('sysctl -w net.ipv6.conf.all.disable_ipv6=1 &>"/dev/null"')
os.system('sysctl -w net.ipv6.conf.default.disable_ipv6=1 &>"/dev/null"')


def alert_if_running():
if os.path.exists('/var/lib/torall/started'):
print_logo()
Expand Down Expand Up @@ -155,6 +171,8 @@ def start_torall():
if os.system('systemctl is-active --quiet tor') == 0:
stop_tor_service()
switch_nameservers()
backup_sysctl()
disable_ipv6()
start_daemon()
set_iptables()
print(MARGIN + clr.BLUE + 'Fetching new IP... ' + clr.GREEN + ip() + clr.END + '\n')
Expand All @@ -168,6 +186,7 @@ def stop_torall():
alert_if_clearnet()
print(MARGIN + clr.RED + clr.BOLD + 'STOPPING TorAll service...' + clr.END)
restore_nameservers()
restore_sysctl()
flush_iptables()
restart_network_manager()
print(MARGIN + clr.BLUE + 'Fetching current IP... ' + clr.END + ip() + '\n')
Expand Down

0 comments on commit aef55bf

Please sign in to comment.