mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-02-12 10:31:51 +00:00
Clean code
This commit is contained in:
parent
d4e7a680f1
commit
dc18217c8e
9 changed files with 25 additions and 25 deletions
|
@ -2,7 +2,6 @@
|
|||
# Copyright (C) 2018-2020 Ycarus (Yannick Chabanois) <ycarus@zugaina.org>
|
||||
|
||||
START=98
|
||||
STOP=10
|
||||
USE_PROCD=1
|
||||
EXTRA_COMMANDS="reload_rules bypass_asn"
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
# Copyright (C) 2018-2024 Ycarus (Yannick Chabanois) <ycarus@zugaina.org> for OpenMPTCProuter
|
||||
|
||||
START=98
|
||||
STOP=10
|
||||
USE_PROCD=1
|
||||
EXTRA_COMMANDS="reload_rules bypass_asn"
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Copyright (C) 2018-2023 Ycarus (Yannick Chabanois) <ycarus@zugaina.org> for OpenMPTCProuter
|
||||
#
|
||||
|
|
|
@ -330,7 +330,7 @@ set_route_balancing() {
|
|||
local multipath_config_route interface_gw interface_if
|
||||
INTERFACE=$1
|
||||
[ -z "$INTERFACE" ] && return
|
||||
[ "$INTERFACE" = "omrvpn" ] && continue
|
||||
[ "$INTERFACE" = "omrvpn" ] && return
|
||||
multipath_config_route=$(uci -q get openmptcprouter.$INTERFACE.multipath)
|
||||
[ -z "$multipath_config_route" ] && multipath_config_route=$(uci -q get network.$INTERFACE.multipath || echo "off")
|
||||
[ "$(uci -q get openmptcprouter.$INTERFACE.multipathvpn)" = "1" ] && {
|
||||
|
@ -390,8 +390,8 @@ set_route_balancing6() {
|
|||
local multipath_config_route interface_gw interface_if
|
||||
INTERFACE=$1
|
||||
[ -z "$INTERFACE" ] && return
|
||||
[ "$INTERFACE" = "omr6in4" ] && continue
|
||||
[ "$INTERFACE" = "omrvpn" ] && continue
|
||||
[ "$INTERFACE" = "omr6in4" ] && return
|
||||
[ "$INTERFACE" = "omrvpn" ] && return
|
||||
multipath_config_route=$(uci -q get openmptcprouter.$INTERFACE.multipath)
|
||||
[ -z "$multipath_config_route" ] && multipath_config_route=$(uci -q get network.$INTERFACE.multipath || echo "off")
|
||||
[ "$(uci -q get openmptcprouter.$INTERFACE.multipathvpn)" = "1" ] && {
|
||||
|
|
|
@ -7,18 +7,19 @@ timeout=$(uci -q get openmptcprouter.settings.status_getip_timeout)
|
|||
[ -z "$timeout" ] && timeout="1"
|
||||
|
||||
get_ip_from_server() {
|
||||
[ -n "$ip" ] && return
|
||||
serverport=$(uci -q get openmptcprouter.$1.port)
|
||||
get_ip() {
|
||||
[ -n "$ip" ] && return
|
||||
serverip=$1
|
||||
getip="$(curl -s -k -4 -m ${timeout} --interface $intf https://$serverip:$serverport/clienthost)"
|
||||
[ -n "$getip" ] && getip=$(echo $getip | jsonfilter -e '@.client_host' | sed 's/::ffff://')
|
||||
if expr "$getip" : '[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*$' >/dev/null; then
|
||||
ip=$getip
|
||||
break
|
||||
return
|
||||
fi
|
||||
}
|
||||
config_list_foreach $1 ip get_ip
|
||||
[ -n "$ip" ] && break
|
||||
}
|
||||
|
||||
get_ip_from_website() {
|
||||
|
@ -30,7 +31,6 @@ get_ip_from_website() {
|
|||
ipset del ss_rules_dst_bypass_all $checkip > /dev/null 2>&1
|
||||
if expr "$getip" : '[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*$' >/dev/null; then
|
||||
ip=$getip
|
||||
break
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
|
@ -7,17 +7,18 @@ timeout=$(uci -q get openmptcprouter.settings.status_getip_timeout)
|
|||
[ -z "$timeout" ] && timeout="1"
|
||||
|
||||
get_ip_from_server() {
|
||||
[ -n "$ip" ] && return
|
||||
serverport=$(uci -q get openmptcprouter.$1.port)
|
||||
get_ip() {
|
||||
[ -n "$ip" ] && return
|
||||
getip="$(curl -s -k -6 -m ${timeout} --interface $intf https://$serverip:$serverport/clienthost)"
|
||||
[ -n "$getip" ] && getip=$(echo $getip | jsonfilter -e '@.client_host')
|
||||
if [ -n "$(echo "$getip" | grep :)" ]; then
|
||||
ip=$getip
|
||||
break
|
||||
return
|
||||
fi
|
||||
}
|
||||
config_list_foreach $1 ip get_ip
|
||||
[ -n "$ip" ] && break
|
||||
}
|
||||
|
||||
get_ip_from_website() {
|
||||
|
@ -29,7 +30,6 @@ get_ip_from_website() {
|
|||
ipset del ss_rules6_dst_bypass_all $checkip > /dev/null 2>&1
|
||||
if [ -n "$(echo "$getip" | grep :)" ]; then
|
||||
ip=$getip
|
||||
break
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
|
@ -8,8 +8,10 @@ timeout="$(uci -q get openmptcprouter.settings.status_vps_timeout)"
|
|||
[ -z "$intf" ] && return
|
||||
|
||||
get_mptcp_from_server() {
|
||||
[ -n "$support" ] && return
|
||||
serverport=$(uci -q get openmptcprouter.$1.port)
|
||||
get_mptcp() {
|
||||
[ -n "$support" ] && return
|
||||
serverip=$1
|
||||
if [ "$(echo $serverip | grep :)" ]; then
|
||||
if [ -f /proc/sys/net/mptcp/enabled ]; then
|
||||
|
@ -26,11 +28,10 @@ get_mptcp_from_server() {
|
|||
fi
|
||||
[ -n "$support" ] && {
|
||||
support=$(echo $support | jsonfilter -e '@.mptcp')
|
||||
break
|
||||
return
|
||||
}
|
||||
}
|
||||
config_list_foreach $1 ip get_mptcp
|
||||
[ -n "$support" ] && break
|
||||
}
|
||||
|
||||
get_mptcpv0_from_website() {
|
||||
|
|
|
@ -43,6 +43,7 @@ _login() {
|
|||
if [ -z "$token" ]; then
|
||||
login_on_server() {
|
||||
server=$1
|
||||
[ -n "$token" ] && return
|
||||
#auth=`curl --max-time 10 -s -k -H "Content-Type: application/json" -X POST -d '{"username":"'$username'","password":"'$password'"}' https://$server:$serverport/login`
|
||||
resolve="$(resolveip -t 5 $server)"
|
||||
valid_ip6=$(valid_subnet6 $server)
|
||||
|
@ -61,10 +62,10 @@ _login() {
|
|||
[ -n "$auth" ] && break
|
||||
done
|
||||
fi
|
||||
[ -z "$auth" ] && return
|
||||
[ -n "$auth" ] && {
|
||||
token="$(echo "$auth" | jsonfilter -q -e '@.access_token')"
|
||||
uci -q set openmptcprouter.${servername}.token="$token"
|
||||
[ -n "$token" ] && break
|
||||
}
|
||||
}
|
||||
config_load openmptcprouter
|
||||
config_list_foreach ${servername} ip login_on_server
|
||||
|
@ -1717,7 +1718,7 @@ _set_config_from_vps() {
|
|||
v2ray_key="$(echo "$vps_config" | jsonfilter -q -e '@.v2ray.config.key')"
|
||||
#v2ray_port="$(echo "$vps_config" | jsonfilter -q -e '@.v2ray.config.port')"
|
||||
v2ray_port="65228"
|
||||
if [ -n "$(uci -q get v2ray.omr)" ] && (([ -n "$v2ray_key" ] && [ "$v2ray_key" != "$(uci -q get v2ray.omrout.s_vmess_user_id)" ]) || ([ -n "$v2ray_port" ] && [ "$v2ray_port" != "$(uci -q get v2ray.omrout.s_vmess.port)" ])); then
|
||||
if [ -n "$(uci -q get v2ray.omr)" ] && ( ([ -n "$v2ray_key" ] && [ "$v2ray_key" != "$(uci -q get v2ray.omrout.s_vmess_user_id)" ]) || ([ -n "$v2ray_port" ] && [ "$v2ray_port" != "$(uci -q get v2ray.omrout.s_vmess.port)" ]) ); then
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
set v2ray.omrout.s_socks_user_id="$v2ray_key"
|
||||
set v2ray.omrout.s_socks_port="$((v2ray_port+3))"
|
||||
|
@ -1749,7 +1750,7 @@ _set_config_from_vps() {
|
|||
xray_vless_reality_key="$(echo "$vps_config" | jsonfilter -q -e '@.xray.config.vless_reality_key')"
|
||||
#v2ray_port="$(echo "$vps_config" | jsonfilter -q -e '@.v2ray.config.port')"
|
||||
xray_port="65248"
|
||||
if [ -n "$(uci -q get xray.omr)" ] && (([ -n "$xray_key" ] && [ "$xray_key" != "$(uci -q get xray.omrout.s_vmess_user_id)" ]) || ([ -n "$xray_port" ] && [ "$xray_port" != "$(uci -q get xray.omrout.s_vmess.port)" ])); then
|
||||
if [ -n "$(uci -q get xray.omr)" ] && ( ([ -n "$xray_key" ] && [ "$xray_key" != "$(uci -q get xray.omrout.s_vmess_user_id)" ]) || ([ -n "$xray_port" ] && [ "$xray_port" != "$(uci -q get xray.omrout.s_vmess.port)" ]) ); then
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
set xray.omrout.s_shadowsocks_port="$((xray_port+4))"
|
||||
set xray.omrout.s_shadowsocks_password="$xray_sskey"
|
||||
|
@ -1785,7 +1786,7 @@ _set_config_from_vps() {
|
|||
# Glorytun settings
|
||||
glorytun_key="$(echo "$vps_config" | jsonfilter -q -e '@.glorytun.key')"
|
||||
glorytun_port="$(echo "$vps_config" | jsonfilter -q -e '@.glorytun.port')"
|
||||
if [ -n "$(uci -q get glorytun.vpn)" ] && (([ -n "$glorytun_key" ] && [ "$glorytun_key" != "$(uci -q get glorytun.vpn.key)" ]) || ([ -n "$glorytun_port" ] || [ "$glorytun_port" != "$(uci -q get glorytun.vpn.port)" ])); then
|
||||
if [ -n "$(uci -q get glorytun.vpn)" ] && ( ([ -n "$glorytun_key" ] && [ "$glorytun_key" != "$(uci -q get glorytun.vpn.key)" ]) || ([ -n "$glorytun_port" ] || [ "$glorytun_port" != "$(uci -q get glorytun.vpn.port)" ]) ); then
|
||||
vpn="$(uci -q get openmptcprouter.settings.vpn)"
|
||||
glorytun_state=0
|
||||
if [ "$vpn" = "glorytun_tcp" ]; then
|
||||
|
@ -1810,7 +1811,7 @@ _set_config_from_vps() {
|
|||
/etc/init.d/glorytun restart >/dev/null 2>&1
|
||||
fi
|
||||
fi
|
||||
if [ -n "$(uci -q get glorytun.udp)" ] && (([ -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
|
||||
if [ -n "$(uci -q get glorytun.udp)" ] && ( ([ -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
|
||||
|
@ -1964,7 +1965,7 @@ _set_config_from_vps() {
|
|||
# DSVPN settings
|
||||
dsvpn_key="$(echo "$vps_config" | jsonfilter -q -e '@.dsvpn.key')"
|
||||
dsvpn_port="$(echo "$vps_config" | jsonfilter -q -e '@.dsvpn.port')"
|
||||
if [ -f /etc/init.d/dsvpn ] && [ -n "$(uci -q get dsvpn.vpn)" ] && (([ -n "$dsvpn_key" ] && [ "$dsvpn_key" != "$(uci -q get dsvpn.vpn.key)" ]) || ([ -n "$dsvpn_port" ] && [ "$dsvpn_port" != "$(uci -q get dsvpn.vpn.port)" ])); then
|
||||
if [ -f /etc/init.d/dsvpn ] && [ -n "$(uci -q get dsvpn.vpn)" ] && ( ([ -n "$dsvpn_key" ] && [ "$dsvpn_key" != "$(uci -q get dsvpn.vpn.key)" ]) || ([ -n "$dsvpn_port" ] && [ "$dsvpn_port" != "$(uci -q get dsvpn.vpn.port)" ]) ); then
|
||||
dsvpn_state=0
|
||||
if [ "$vpn" = "dsvpn" ]; then
|
||||
dsvpn_state=1
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
#!/bin/sh /etc/rc.common
|
||||
|
||||
EXTRA_COMMANDS="backup restore"
|
||||
EXTRA_HELP=<<EOF
|
||||
backup Backup vnstat database
|
||||
EXTRA_HELP=" backup Backup vnstat database
|
||||
restore Restore vnstat database
|
||||
EOF
|
||||
"
|
||||
|
||||
START=50
|
||||
STOP=60
|
||||
|
|
Loading…
Reference in a new issue