Last active
September 16, 2021 03:02
-
-
Save dylanschmittle/4bb0780a3199876cd8823450327e63c5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
reset_multitor () { | |
multitor -s -n --init 10 --user tor --socks-port 9009 --control-port 9900 --proxy privoxy --haproxy | |
sleep 30 | |
} | |
reset_tor () { | |
reset_multitor | |
sv restart tor | |
} | |
reset_dns () { | |
sv restart dnscrypt-proxy | |
sv restart unbound | |
} | |
reset_routes () { | |
sv restart nftables | |
sv restart wpa_supplicant | |
sv restart dhcpcd | |
sv restart wireguard | |
sv restart sshd | |
} | |
check_ip_ping () { | |
ping -q -c 1 8.8.8.8 &>/dev/null | |
} | |
check_host_ping () { | |
ping -q -c 1 google.com &>/dev/null | |
} | |
check_ssh_tor () { | |
nc -X 5 -x 127.0.0.1:9050 -z void.showmewhatyougot.live 57885 &>/dev/null | |
} | |
reset_network () { | |
reset_routes | |
} | |
while : | |
do | |
if check_host_ping | |
then | |
echo "PING WORKS USING HOSTNAME - CHECK SSH" | |
else | |
echo "PING FAILS USING HOSTNAME - RESET TOR - CHECK DNS" | |
reset_tor | |
if check_ip_ping | |
then | |
echo "PING WORKS USING IP ONLY - RESET DNS" | |
reset_dns | |
else | |
echo "BOTH PINGS FAIL - FULL RESET" | |
network-restart | |
fi | |
fi | |
if check_ssh_tor | |
then | |
echo "SSH VIA TORSOCKS SUCCESS - END CHECK" | |
else | |
echo "SSH FAILED - RESET ALL BUT DNS" | |
reset_routes | |
reset_tor | |
fi | |
sleep 60 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment