-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathstart.sh
executable file
·43 lines (36 loc) · 854 Bytes
/
start.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env bash
VPNGATE_URL=http://www.vpngate.net/api/iphone/
function global_ip {
curl -s inet-ip.info
}
# vpn connect func
function connect {
while :; do
echo start
while read line; do
line=$(echo $line | cut -d ',' -f 15)
line=$(echo $line | tr -d '\r')
openvpn <(echo "$line" | base64 -d) ;
done < <(curl -s $VPNGATE_URL | grep ,Japan,JP, | grep -v public-vpn- | sort -R )
echo end
done
}
BEFORE_IP="$(global_ip)"
# start proxy
privoxy <(grep -v listen-address /etc/privoxy/config ; echo listen-address 0.0.0.0:8118) &
# connect vpn
connect &
# vpn check
while :; do
sleep 5
AFTER_IP=$(global_ip)
result=$?
echo "before=$BEFORE_IP after=$AFTER_IP"
if [ $result -ne 0 ]; then
pkill openvpn
elif [ "$BEFORE_IP" = "$AFTER_IP" ]; then
pkill openvpn
else
sleep 55
fi
done