-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathentrypoint.sh
60 lines (52 loc) · 1.57 KB
/
entrypoint.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/sh
TUN="${TUN:-tun0}"
MTU="${MTU:-9000}"
IPV4="${IPV4:-198.18.0.1}"
IPV6="${IPV6:-}"
MARK="${MARK:-438}"
SOCKS5_UDP_MODE="${SOCKS5_UDP_MODE:-udp}"
OTHER_ROUTE="${OTHER_ROUTE:-}"
LOG_LEVEL="${LOG_LEVEL:-warn}"
GATEWAY="${GATEWAY:-$(ip route | awk '/default/ && /eth0/ {print $3}')}"
config_file() {
cat > /hs5t.yml << EOF
misc:
log-level: '${LOG_LEVEL}'
tunnel:
name: '${TUN}'
mtu: ${MTU}
ipv4: '${IPV4}'
ipv6: '${IPV6}'
post-up-script: '/route.sh'
socks5:
address: '127.0.0.1'
port: 1080
udp: '${SOCKS5_UDP_MODE}'
mark: ${MARK}
EOF
}
config_route() {
echo "#!/bin/sh" > /route.sh
chmod +x /route.sh
echo "ip rule add from all uidrange 1000-1000 lookup 110 pref 28000" >> /route.sh
echo "ip route flush table 110" >> /route.sh
echo "ip route add default via $GATEWAY dev eth0 metric 50 table 110" >> /route.sh
echo "ip route del default" >> /route.sh
echo "ip route add default via ${IPV4} dev ${TUN} metric 1" >> /route.sh
echo "ip route add default via $GATEWAY dev eth0 metric 10" >> /route.sh
# exclude local network
echo "ip route add 10.0.0.0/8 via $GATEWAY dev eth0" >> /route.sh
echo "ip route add 172.16.0.0/12 via $GATEWAY dev eth0" >> /route.sh
echo "ip route add 192.168.0.0/16 via $GATEWAY dev eth0" >> /route.sh
echo "${OTHER_ROUTE}" >> /route.sh
}
run() {
config_file
config_route
echo "echo 1 > /success" >> /route.sh
echo "ByeDPI v.$(ciadpi --version)"
echo "hev-socks5-tunnel $(hev-socks5-tunnel --version | head -n 2 | tail -n 1)"
hev-socks5-tunnel /hs5t.yml &
su - ciadpi -c "ciadpi $*"
}
run "$@" || exit 1