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
|
||||
|
|
|
@ -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