1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-feeds.git synced 2025-02-14 19:41:51 +00:00

Add Shadowsocks-Rust support in mptcpovervpn init script

This commit is contained in:
Ycarus (Yannick Chabanois) 2024-09-10 18:09:53 +02:00
parent 971d82b5d6
commit 2b64a62e90

View file

@ -232,16 +232,32 @@ start_service()
fi
if [ "$nbintf" = "$nbintfvpn" ] && [ "$nbintf" != "0" ]; then
if [ "$vpn" = "openvpn" ]; then
if [ "$(uci -q get openmptcprouter.settings.proxy)" = "shadowsocks" ]; then
uci -q batch <<-EOF >/dev/null
set shadowsocks-libev.sss0.disabled='1'
EOF
elif [ "$(uci -q get openmptcprouter.settings.proxy)" = "shadowsocks-rust" ]; then
uci -q batch <<-EOF >/dev/null
set shadowsocks-rust.sss0.disabled='1'
EOF
fi
uci -q batch <<-EOF >/dev/null
set shadowsocks-libev.sss0.disabled='1'
set glorytun.vpn.host='10.255.250.1'
set glorytun-udp.vpn.host='10.255.250.1'
commit glorytun
commit glorytun-udp
EOF
else
if [ "$(uci -q get openmptcprouter.settings.proxy)" = "shadowsocks" ]; then
uci -q batch <<-EOF >/dev/null
set shadowsocks-libev.sss0.disabled='1'
EOF
elif [ "$(uci -q get openmptcprouter.settings.proxy)" = "shadowsocks-rust" ]; then
uci -q batch <<-EOF >/dev/null
set shadowsocks-rust.sss0.disabled='1'
EOF
fi
uci -q batch <<-EOF >/dev/null
set shadowsocks-libev.sss0.disabled='1'
set glorytun.vpn.host='10.255.247.1'
set glorytun-udp.vpn.host='10.255.247.1'
commit glorytun
@ -251,11 +267,22 @@ start_service()
uci -q batch <<-EOF >/dev/null
set shadowsocks-libev.ss_rules.server='mptcpovervpn'
set shadowsocks-libev.ss_rules.redir_tcp='all'
set shadowsocks-rust.ss_rules.server='mptcpovervpn'
set shadowsocks-rust.ss_rules.redir_tcp='all'
EOF
elif ([ "$(uci -q get glorytun.vpn.host)" = "10.255.250.1" ] || [ "$(uci -q get glorytun.vpn.host)" = "10.255.247.1" ] || [ "$(uci -q get shadowsocks-libev.ss_rules.server)" != "sss0" ]) && [ "$nbintf" != "$nbintfvpn" ]; then
elif ([ "$(uci -q get glorytun.vpn.host)" = "10.255.250.1" ] || [ "$(uci -q get glorytun.vpn.host)" = "10.255.247.1" ] || [ "$(uci -q get shadowsocks-libev.ss_rules.server)" != "sss0" ] || [ "$(uci -q get shadowsocks-rust.ss_rules.server)" != "sss0" ]) && [ "$nbintf" != "$nbintfvpn" ]; then
if [ "$(uci -q get openmptcprouter.settings.proxy)" = "shadowsocks" ]; then
uci -q batch <<-EOF >/dev/null
set shadowsocks-libev.sss0.disabled='0'
EOF
elif [ "$(uci -q get openmptcprouter.settings.proxy)" = "shadowsocks-rust" ]; then
uci -q batch <<-EOF >/dev/null
set shadowsocks-rust.sss0.disabled='0'
EOF
fi
uci -q batch <<-EOF >/dev/null
set shadowsocks-libev.sss0.disabled='0'
set shadowsocks-libev.ss_rules.server='sss0'
set shadowsocks-rust.ss_rules.server='sss0'
set glorytun.vpn.host="$(uci -q get openmptcprouter.vps.ip | awk '{print $1}')"
set glorytun-udp.vpn.host="$(uci -q get openmptcprouter.vps.ip | awk '{print $1}')"
commit glorytun
@ -263,7 +290,7 @@ start_service()
EOF
fi
NBCPU=$(grep -c '^processor' /proc/cpuinfo | tr -d "\n")
if [ "$nbintfvpn" != 0 ]; then
if [ "$nbintfvpn" != 0 ] && [ "$(uci -q get openmptcprouter.settings.proxy)" = "shadowsocks" ]; then
if [ "$vpn" = "openvpn" ]; then
uci -q batch <<-EOF >/dev/null
set shadowsocks-libev.mptcpovervpn=server
@ -305,6 +332,46 @@ start_service()
EOF
/etc/init.d/shadowsocks-libev restart
/etc/init.d/openvpn restart
elif [ "$nbintfvpn" != 0 ] && [ "$(uci -q get openmptcprouter.settings.proxy)" = "shadowsocks-rust" ]; then
if [ "$vpn" = "openvpn" ]; then
uci -q batch <<-EOF >/dev/null
set shadowsocks-rust.mptcpovervpn=server
set shadowsocks-rust.mptcpovervpn.server_port="$(uci -q get shadowsocks-rust.sss0.server_port)"
set shadowsocks-rust.mptcpovervpn.password="$(uci -q get shadowsocks-rust.sss0.password)"
set shadowsocks-rust.mptcpovervpn.method="$(uci -q get shadowsocks-rust.sss0.method)"
set shadowsocks-rust.mptcpovervpn.server="10.255.250.1"
set shadowsocks-rust.mptcpovervpn.disabled='0'
EOF
else
uci -q batch <<-EOF >/dev/null
set shadowsocks-rust.mptcpovervpn=server
set shadowsocks-rust.mptcpovervpn.server_port="$(uci -q get shadowsocks-rust.sss0.server_port)"
set shadowsocks-rust.mptcpovervpn.password="$(uci -q get shadowsocks-rust.sss0.password)"
set shadowsocks-rust.mptcpovervpn.method="$(uci -q get shadowsocks-rust.sss0.method)"
set shadowsocks-rust.mptcpovervpn.server="10.255.247.1"
set shadowsocks-rust.mptcpovervpn.disabled='0'
EOF
fi
uci -q batch <<-EOF >/dev/null
set shadowsocks-rust.hivpn=ss_redir
set shadowsocks-rust.hivpn.server="mptcpovervpn"
set shadowsocks-rust.hivpn.local_address='0.0.0.0'
set shadowsocks-rust.hivpn.local_port='1101'
set shadowsocks-rust.hivpn.mode='tcp_and_udp'
set shadowsocks-rust.hivpn.timeout='1000'
set shadowsocks-rust.hivpn.fast_open='1'
set shadowsocks-rust.hivpn.verbose='0'
set shadowsocks-rust.hivpn.syslog='1'
set shadowsocks-rust.hivpn.reuse_port='1'
set shadowsocks-rust.hivpn.mptcp='1'
set shadowsocks-rust.hivpn.ipv6_first='1'
set shadowsocks-rust.hivpn.no_delay='1'
EOF
uci -q batch <<-EOF >/dev/null
commit shadowsocks-rust
EOF
/etc/init.d/shadowsocks-rust restart
/etc/init.d/openvpn restart
elif [ "$(uci -q get shadowsocks-libev.hivpn1)" != "" ]; then
for c in $(seq 1 $NBCPU); do
uci -q batch <<-EOF >/dev/null
@ -312,12 +379,24 @@ start_service()
EOF
done
uci -q batch <<-EOF >/dev/null
set shadowsocks-libev.sss0.disabled='0'
delete shadowsocks-rust.hivpn
EOF
if [ "$(uci -q get openmptcprouter.settings.proxy)" = "shadowsocks" ]; then
uci -q batch <<-EOF >/dev/null
set shadowsocks-libev.sss0.disabled='0'
EOF
elif [ "$(uci -q get openmptcprouter.settings.proxy)" = "shadowsocks-rust" ]; then
uci -q batch <<-EOF >/dev/null
set shadowsocks-rust.sss0.disabled='0'
EOF
fi
uci -q batch <<-EOF >/dev/null
set shadowsocks-libev.ss_rules.server='sss0'
set shadowsocks-rust.ss_rules.server='sss0'
delete shadowsocks-libev.mptcpovervpn
commit shadowsocks-libev
delete shadowsocks-rust.mptcpovervpn
commit shadowsocks-rust
EOF
fi
if [ "$BOOT" = "1" ]; then