Skip to content

Instantly share code, notes, and snippets.

@dylanschmittle
Last active September 16, 2021 03:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dylanschmittle/4bb0780a3199876cd8823450327e63c5 to your computer and use it in GitHub Desktop.
Save dylanschmittle/4bb0780a3199876cd8823450327e63c5 to your computer and use it in GitHub Desktop.
#!/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