Skip to content

Instantly share code, notes, and snippets.

@ipcjs
Created December 16, 2020 14:01
Show Gist options
  • Save ipcjs/8ee74178c4a96c943760aec9384f6db3 to your computer and use it in GitHub Desktop.
Save ipcjs/8ee74178c4a96c943760aec9384f6db3 to your computer and use it in GitHub Desktop.
使用腾讯加速器模式一加速代理服务器 : )
#!/bin/bash
# you proxy server ip
ip="172.105.237.77"
function setup_route() {
# obtain gateway
gateway=""
while [ "$gateway" = "" ]; do
sleep 2s
gateway=$(route.exe print "10.*" | awk '$2 == "255.255.255.255" && $3 ~ /^10\.[0-9]\.[0-9]+\.([2-9]|[0-9]{2,})$/ {print $3}')
echo "gateway=$gateway"
done
route.exe delete $ip
route.exe add $ip mask 255.255.255.255 "$gateway" metric 10
}
function check_ip_gateway_exist() {
_ip=$1
_gateway=$2
if [ "$(route.exe print "$_ip" | awk -v i="$_ip" -v w="$_gateway" '$1 == i && $3 == w {print $1}')" ]; then
return 0
else
return 1
fi
}
setup_count=0
while true; do
echo "$((++setup_count)) time: $(date)"
setup_route
if [ "$setup_count" -le 1 ]; then
while check_ip_gateway_exist $ip "$gateway"; do
echo "found->$ip/$gateway"
sleep 3s
done
else
echo "wait 5min and then check"
sleep 4m 55s
while check_ip_gateway_exist $ip "$gateway"; do
echo "found: $ip/$gateway"
sleep 1s
echo
done
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment