1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-feeds.git synced 2025-03-09 15:40:03 +00:00

Add glorytun-udp new splitted config in mptcp over vpn and vps api contact

This commit is contained in:
Ycarus (Yannick Chabanois) 2020-12-03 11:31:05 +01:00
parent c407a885dd
commit cc9f3c9fe6
2 changed files with 61 additions and 13 deletions

View file

@ -132,11 +132,17 @@ start_service()
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
elif [ "$(uci -q get glorytun.vpn.host)" = "10.255.250.1" ] && [ "$nbintf" != "$nbintfvpn" ]; then
uci -q batch <<-EOF >/dev/null
delete shadowsocks-libev.sss0.disabled
set glorytun.vpn.host="$(uci -q get openmptcprouter.vps.ip)"
set glorytun-udp.vpn.host="$(uci -q get openmptcprouter.vps.ip)"
commit glorytun
commit glorytun-udp
EOF
fi
NBCPU=$(grep -c '^processor' /proc/cpuinfo | tr -d "\n")

View file

@ -296,20 +296,20 @@ _get_vps_config() {
fi
if [ "$vpn" = "glorytun_udp" ]; then
glorytun_state=1
uci -q set glorytun.vpn.proto='udp'
#uci -q set glorytun.vpn.proto='udp'
client_ip="$(echo "$vps_config" | jsonfilter -q -e '@.glorytun.udp.client_ip')"
host_ip="$(echo "$vps_config" | jsonfilter -q -e '@.glorytun.udp.host_ip')"
port="$(echo "$vps_config" | jsonfilter -q -e '@.glorytun.port')"
if [ "$(uci -q get glorytun.vpn.port)" != "$port" ] && [ "$port" != "" ]; then
if [ "$(uci -q get glorytun-udp.vpn.port)" != "$port" ] && [ "$port" != "" ]; then
uci -q batch <<-EOF >/dev/null
set glorytun.vpn.port=$port
set glorytun-udp.vpn.port=$port
EOF
fi
if [ "$client_ip" != "dhcp" ] && [ -n "$client_ip" ]; then
if [ "$host_ip" != "$(uci -q get glorytun.vpn.remoteip)" ] || [ "$client_ip" != "$(uci -q get glorytun.vpn.localip)" ]; then
if [ "$host_ip" != "$(uci -q get glorytun-udp.vpn.remoteip)" ] || [ "$client_ip" != "$(uci -q get glorytun-udp.vpn.localip)" ]; then
uci -q batch <<-EOF >/dev/null
set glorytun.vpn.localip=$client_ip
set glorytun.vpn.remoteip=$host_ip
set glorytun-udp.vpn.localip=$client_ip
set glorytun-udp.vpn.remoteip=$host_ip
EOF
glorytun_change=1
fi
@ -321,10 +321,10 @@ _get_vps_config() {
glorytun_change=1
fi
else
if [ "$(uci -q get glorytun.vpn.remoteip)" != "" ] || [ "$(uci -q get glorytun.vpn.localip)" != "" ]; then
if [ "$(uci -q get glorytun-udp.vpn.remoteip)" != "" ] || [ "$(uci -q get glorytun-udp.vpn.localip)" != "" ]; then
uci -q batch <<-EOF >/dev/null
delete glorytun.vpn.localip
delete glorytun.vpn.remoteip
delete glorytun-udp.vpn.localip
delete glorytun-udp.vpn.remoteip
EOF
glorytun_change=1
fi
@ -403,14 +403,24 @@ _get_vps_config() {
EOF
glorytun_change=1
fi
if [ "$(uci -q get glorytun-udp.vpn.host)" != "127.0.0.1" ] && [ "$(uci -q get glorytun-udp.vpn.host)" != "$vpsip" ] && [ "$(uci -q get openmptcprouter.settings.ha)" != "1" ]; then
uci -q batch <<-EOF >/dev/null
set glorytun-udp.vpn.host="$vpsip"
EOF
glorytun_change=1
fi
if [ "$glorytun_change" != "0" ]; then
uci -q batch <<-EOF >/dev/null
commit glorytun
commit glorytun-udp
EOF
if [ "$(uci -q get glorytun.vpn.enable)" = "1" ]; then
logger -t "OMR-VPS" "Restart glorytun..."
/etc/init.d/glorytun restart >/dev/null 2>&1
fi
if [ "$(uci -q get glorytun-udp.vpn.enable)" = "1" ]; then
logger -t "OMR-VPS" "Restart glorytun-udp..."
/etc/init.d/glorytun-udp restart >/dev/null 2>&1
fi
fi
@ -1148,9 +1158,6 @@ _set_config_from_vps() {
if [ "$vpn" = "glorytun_tcp" ]; then
glorytun_state=1
fi
if [ "$vpn" = "glorytun_udp" ]; then
glorytun_state=1
fi
[ -z "$glorytun_port" ] && glorytun_port="65001"
glorytun_chacha="$(echo "$vps_config" | jsonfilter -q -e '@.glorytun.chacha')"
[ -z "$glorytun_chacha" ] || [ "$glorytun_chacha" = "true" ] && glorytun_chacha=1
@ -1167,6 +1174,28 @@ _set_config_from_vps() {
uci -q commit glorytun
logger -t "OMR-VPS" "Glorytun restart..."
/etc/init.d/glorytun restart >/dev/null 2>&1
fi
if ([ -n "$glorytun_key" ] && [ "$glorytun_key" != "$(uci -q get glorytun-udp.vpn.key)" ]) || ([ -n "$glorytun_port" ] || [ "$glorytun_port" != "$(uci -q get glorytun-udp.vpn.port)" ]); then
vpn="$(uci -q get openmptcprouter.settings.vpn)"
glorytun_state=0
if [ "$vpn" = "glorytun_udp" ]; then
glorytun_state=1
fi
[ -z "$glorytun_port" ] && glorytun_port="65001"
glorytun_chacha="$(echo "$vps_config" | jsonfilter -q -e '@.glorytun.chacha')"
[ -z "$glorytun_chacha" ] || [ "$glorytun_chacha" = "true" ] && glorytun_chacha=1
[ "$glorytun_chacha" = "false" ] && glorytun_chacha=0
uci -q batch <<-EOF >/dev/null
set glorytun-udp.vpn.port=$glorytun_port
set glorytun-udp.vpn.key=$glorytun_key
set glorytun-udp.vpn.enable=$glorytun_state
set glorytun-udp.vpn.chacha=$glorytun_chacha
EOF
if [ "$(uci -q get glorytun-udp.vpn.host)" != "127.0.0.1" ]; then
uci -q set glorytun-udp.vpn.host="$vpsip"
fi
uci -q commit glorytun-udp
logger -t "OMR-VPS" "Glorytun UDP restart..."
/etc/init.d/glorytun-udp restart >/dev/null 2>&1
fi
@ -1535,6 +1564,14 @@ _config_service() {
return
}
error=0
if [ -n "$serial" ]; then
[ -z "$vps_config" ] && vps_config=$(_get_json "config?serial=${serial}")
if [ -n "$vps_config" ] && [ "$( echo "$vps_config" | jsonfilter -q -e '@.error')" = "False serial number" ]; then
logger -t "OMR-VPS" "Invalid serial number"
sed -i "s:${server}::g" /etc/config/*
return
fi
fi
[ "$(uci -q get openmptcprouter.${servername}.get_config)" = "1" ] && [ "$(uci -q get openmptcprouter.${servername}.master)" = "1" ] && {
_set_config_from_vps
_get_gre_tunnel
@ -1555,6 +1592,8 @@ _config_service() {
uci -q batch <<-EOF >/dev/null
set glorytun.vpn.chacha20="0"
commit glorytun
set glorytun-udp.vpn.chacha="0"
commit glorytun-udp
EOF
config_foreach _set_ss_server server "method" "aes-256-gcm"
uci -q commit shadowsocks-libev
@ -1631,6 +1670,9 @@ set_pihole() {
start_service() {
serversnb=0
wanips=""
serial=$(cat /proc/cpuinfo | grep Serial | awk '{print $3}')
[ -z "$serial" ] && [ -f "/usr/sbin/dmidecode" ] && serial=$(/usr/sbin/dmidecode -t 1 | egrep 'Serial' | awk '{print $3}')
uci -q set openmptcprouter.settings.serial=${serial}
config_load openmptcprouter
config_foreach _count_server server
config_foreach _get_local_wan_ip interface
@ -1642,6 +1684,6 @@ start_service() {
}
service_triggers() {
procd_add_reload_trigger openmptcprouter shadowsocks-libev glorytun mlvpn openvpn network upnpd dsvpn v2ray firewall
procd_add_reload_trigger openmptcprouter shadowsocks-libev glorytun glorytun-udp mlvpn openvpn network upnpd dsvpn v2ray firewall
#procd_add_reload_trigger openmptcprouter shadowsocks-libev network upnpd
}