Skip to content

Instantly share code, notes, and snippets.

@hosni
Last active July 12, 2021 08:26
Show Gist options
  • Save hosni/b8d0ac411633fd3ece88aac383b74357 to your computer and use it in GitHub Desktop.
Save hosni/b8d0ac411633fd3ece88aac383b74357 to your computer and use it in GitHub Desktop.
Sadly, some of services is behind on Arvan Cloud and is Iran Access! this script fetch all AC IPs and add a route for them for you.
#!/usr/bin/sh
H_ECHO_BIN=/bin/echo
helpMe()
{
$H_ECHO_BIN "";
$H_ECHO_BIN "Add or Delete Arvan Cloud's IPs to your ip routing table.";
$H_ECHO_BIN -e "(in case you don't want to turn of your VPN, and DAMN FilterNet)\n";
$H_ECHO_BIN "Usage: $0 -a action -g gateway";
$H_ECHO_BIN -e "\t-a the action that is 'add' or 'del'";
$H_ECHO_BIN -e "\t-g the gateway (ex: 192.168.1.1)";
exit 1;
}
while getopts "a:g:" opt
do
case "$opt" in
a ) H_ACTION="$OPTARG" ;;
g ) H_GATEWAY="$OPTARG" ;;
? ) helpMe ;;
esac
done
if [ -z "$H_ACTION" ] || [ -z "$H_GATEWAY" ]
then
$H_ECHO_BIN "Some or all of the parameters are empty!";
helpMe;
fi
if [ $H_ACTION != "add" ] && [ $H_ACTION != "del" ]
then
$H_ECHO_BIN "argumet passed to -a is not valid! passed: $H_ACTION";
helpMe;
fi
for i in $(echo `wget -qO - https://arvancloud.com/fa/ips.txt` | tr "\n" "\n")
do
H_COMMAND="ip route $H_ACTION $i via $H_GATEWAY";
$H_ECHO_BIN "run: '$H_COMMAND'";
`$H_COMMAND`;
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment