Created
August 6, 2015 17:38
-
-
Save kiyor/e0115fa4ccf70abd9c6c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
* * * * * if [[ `ip route show | wc -l` -lt 100 ]]; then /config/auth/routeadd.sh >/dev/null 2>&1; fi; | |
30 2 * * * /config/auth/unblockyouku.sh |
This file contains hidden or 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 | |
############################################ | |
# File Name : unblockyouku.sh | |
# Purpose : | |
# Creation Date : 06-03-2015 | |
# Last Modified : Fri Jul 31 12:43:52 2015 | |
# Created By : Kiyor | |
############################################ | |
gateway='10.7.0.1' | |
gatewaydev='vtun0' | |
routeaddf='/config/auth/routeadd.sh' | |
routedelf='/config/auth/routedel.sh' | |
custom='/config/auth/custom' | |
rawurl='https://raw.githubusercontent.com/zhuzhuor/Unblock-Youku/master/shared/urls.js' | |
domain=`curl -s $rawurl | egrep -v "^\s+//" | egrep -o "htt(p|ps)://[^/]+" | egrep -o "/[^/]+" | cut -d '/' -f 2 | grep -v \* | cut -d ':' -f 1 | sort | uniq | sort | grep -v iqiyi | grep -v xiami` | |
echo -n >/tmp/list | |
echo -n >/tmp/list1 | |
echo -n >/tmp/list2 | |
for d in $domain; do | |
if echo $d | egrep -q '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}'; then | |
echo $d >>/tmp/list | |
else | |
if echo $d | egrep -q letv; then | |
if echo $d | egrep -q dynamic; then | |
ip=`dig $d | grep -v ';' | egrep "IN\s+A" | egrep -o '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | sort -n | uniq | sort -n` | |
for i in `echo $ip`; do | |
echo "$i $d" >>/tmp/list | |
done | |
fi | |
else | |
ip=`dig $d | grep -v ';' | egrep "IN\s+A" | egrep -o '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | sort -n | uniq | sort -n` | |
for i in `echo $ip`; do | |
echo "$i $d" >>/tmp/list | |
done | |
fi | |
fi | |
done | |
domain=`cat $custom` | |
for d in $domain; do | |
if echo $d | egrep -q '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}'; then | |
echo $d >>/tmp/list | |
else | |
ip=`dig $d | grep -v ';' | egrep "IN\s+A" | egrep -o '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | sort -n | uniq | sort -n` | |
for i in `echo $ip`; do | |
echo "$i $d" >>/tmp/list | |
done | |
fi | |
done | |
for ip in `cat /tmp/list|awk '{ print $1 }'`; do | |
echo $ip >>/tmp/list1 | |
done | |
echo '#!/bin/sh' >$routeaddf | |
echo '#!/bin/sh' >$routedelf | |
cat /tmp/list1 | sort -n | uniq | sort -n >/tmp/list2 | |
for ip in `cat /tmp/list2`; do | |
echo "/sbin/ip route add $ip/32 via $gateway dev $gatewaydev" >>$routeaddf | |
echo "/sbin/ip route del $ip/32 via $gateway dev $gatewaydev" >>$routedelf | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment