|
|
|
@ -42,7 +42,7 @@ Usage: chntunnel [OPTION...] |
|
|
|
|
options: |
|
|
|
|
-c, --collect genrate route files from apnic. |
|
|
|
|
-g, --gre-tunnel create a gre tunnel. |
|
|
|
|
-w, --white-list whitelist mode.[TODO] |
|
|
|
|
-w, --white-list whitelist mode, only manually.[TODO] |
|
|
|
|
-f, --gfw-list gfwlist mode. |
|
|
|
|
EOF |
|
|
|
|
} |
|
|
|
@ -168,10 +168,13 @@ if [ $# != 0 ]; then |
|
|
|
|
newGre $MY_INNER_IPADDR $PEER_INNER_IPADDR $PEER_OUTER_IPADDR ${TUNNEL_NAME:-tun0} |
|
|
|
|
ifup ${TUNNEL_NAME:-tun0} |
|
|
|
|
ping -c 3 $PEER_INNER_IPADDR >/dev/null && result=$? && [[ $result -eq 0 ]] && msg_pass "Tunnel created successfully!" && exit 0 |
|
|
|
|
msg_err "Connection failed, please contact the administrator." && exit 1 |
|
|
|
|
elif [[ $param = '-f' || $param = '--gfw-list' ]]; then |
|
|
|
|
peer=$(ip addr | grep peer | grep inet | awk -F ' ' {'print $4'}) |
|
|
|
|
PEER_INNER_IPADDR=${peer%%/*} |
|
|
|
|
:>/etc/sysconfig/static-routes |
|
|
|
|
[[ ! -f $GFWLIST ]] && msg_err "Please run 'chntunnel -c' command first." && exit 1 |
|
|
|
|
msg "Generating, wait a while..." |
|
|
|
|
cat $GFWLIST | while read line |
|
|
|
|
do |
|
|
|
|
ip route add $line via $PEER_INNER_IPADDR |
|
|
|
@ -179,7 +182,7 @@ if [ $# != 0 ]; then |
|
|
|
|
done |
|
|
|
|
msg_pass "GFWlist is active, enjoy~" |
|
|
|
|
elif [[ $param = '-w' || $param = '--white-list' ]]; then |
|
|
|
|
msg_err "TODO: not yet implemented, only manually." && exit 1 |
|
|
|
|
#msg_err "TODO: not yet implemented, only manually." && exit 1 |
|
|
|
|
local_gw=$(ip route | grep default | awk -F ' ' {'print $3'}) |
|
|
|
|
#local_dev=$(ip route | grep src | awk -F ' ' {'print $3'}) |
|
|
|
|
#local_addr=$(ip route | grep src | awk -F ' ' {'print $9'}) |
|
|
|
@ -189,15 +192,17 @@ if [ $# != 0 ]; then |
|
|
|
|
:>/etc/sysconfig/static-routes |
|
|
|
|
grep $local_table /etc/iproute2/rt_tables && result=$? |
|
|
|
|
[[ $result != '0' ]] && echo "200 $local_table" >>/etc/iproute2/rt_tables |
|
|
|
|
grep $local_table /etc/rc.local && result=$? |
|
|
|
|
[[ $result != '0' ]] && addRoutes $local_table $local_gw $local_dev $local_addr && chmod +x /etc/rc.local && /etc/rc.local && |
|
|
|
|
#grep $local_table /etc/rc.local && result=$? |
|
|
|
|
#[[ $result != '0' ]] && addRoutes $local_table $local_gw $local_dev $local_addr && chmod +x /etc/rc.local && /etc/rc.local |
|
|
|
|
msg "Generating, wait a while..." |
|
|
|
|
cat $WHITELIST | while read line |
|
|
|
|
do |
|
|
|
|
ip route add $line via $local_gw |
|
|
|
|
#ip route add $line via $local_gw |
|
|
|
|
echo "any net $line gw $local_gw" >>/etc/sysconfig/static-routes || exit |
|
|
|
|
done |
|
|
|
|
#ip route del default via $local_gw |
|
|
|
|
#ip route add default via $PEER_INNER_IPADDR |
|
|
|
|
msg_pass "Whitelist is active, enjoy~" |
|
|
|
|
else |
|
|
|
|
help |
|
|
|
|
fi |
|
|
|
|