mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-03-09 15:40:03 +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>
|
# Copyright (C) 2018-2020 Ycarus (Yannick Chabanois) <ycarus@zugaina.org>
|
||||||
|
|
||||||
START=98
|
START=98
|
||||||
STOP=10
|
|
||||||
USE_PROCD=1
|
USE_PROCD=1
|
||||||
EXTRA_COMMANDS="reload_rules bypass_asn"
|
EXTRA_COMMANDS="reload_rules bypass_asn"
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
# Copyright (C) 2018-2024 Ycarus (Yannick Chabanois) <ycarus@zugaina.org> for OpenMPTCProuter
|
# Copyright (C) 2018-2024 Ycarus (Yannick Chabanois) <ycarus@zugaina.org> for OpenMPTCProuter
|
||||||
|
|
||||||
START=98
|
START=98
|
||||||
STOP=10
|
|
||||||
USE_PROCD=1
|
USE_PROCD=1
|
||||||
EXTRA_COMMANDS="reload_rules bypass_asn"
|
EXTRA_COMMANDS="reload_rules bypass_asn"
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#!/bin/sh
|
||||||
#
|
#
|
||||||
# Copyright (C) 2018-2023 Ycarus (Yannick Chabanois) <ycarus@zugaina.org> for OpenMPTCProuter
|
# 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
|
local multipath_config_route interface_gw interface_if
|
||||||
INTERFACE=$1
|
INTERFACE=$1
|
||||||
[ -z "$INTERFACE" ] && return
|
[ -z "$INTERFACE" ] && return
|
||||||
[ "$INTERFACE" = "omrvpn" ] && continue
|
[ "$INTERFACE" = "omrvpn" ] && return
|
||||||
multipath_config_route=$(uci -q get openmptcprouter.$INTERFACE.multipath)
|
multipath_config_route=$(uci -q get openmptcprouter.$INTERFACE.multipath)
|
||||||
[ -z "$multipath_config_route" ] && multipath_config_route=$(uci -q get network.$INTERFACE.multipath || echo "off")
|
[ -z "$multipath_config_route" ] && multipath_config_route=$(uci -q get network.$INTERFACE.multipath || echo "off")
|
||||||
[ "$(uci -q get openmptcprouter.$INTERFACE.multipathvpn)" = "1" ] && {
|
[ "$(uci -q get openmptcprouter.$INTERFACE.multipathvpn)" = "1" ] && {
|
||||||
|
@ -390,8 +390,8 @@ set_route_balancing6() {
|
||||||
local multipath_config_route interface_gw interface_if
|
local multipath_config_route interface_gw interface_if
|
||||||
INTERFACE=$1
|
INTERFACE=$1
|
||||||
[ -z "$INTERFACE" ] && return
|
[ -z "$INTERFACE" ] && return
|
||||||
[ "$INTERFACE" = "omr6in4" ] && continue
|
[ "$INTERFACE" = "omr6in4" ] && return
|
||||||
[ "$INTERFACE" = "omrvpn" ] && continue
|
[ "$INTERFACE" = "omrvpn" ] && return
|
||||||
multipath_config_route=$(uci -q get openmptcprouter.$INTERFACE.multipath)
|
multipath_config_route=$(uci -q get openmptcprouter.$INTERFACE.multipath)
|
||||||
[ -z "$multipath_config_route" ] && multipath_config_route=$(uci -q get network.$INTERFACE.multipath || echo "off")
|
[ -z "$multipath_config_route" ] && multipath_config_route=$(uci -q get network.$INTERFACE.multipath || echo "off")
|
||||||
[ "$(uci -q get openmptcprouter.$INTERFACE.multipathvpn)" = "1" ] && {
|
[ "$(uci -q get openmptcprouter.$INTERFACE.multipathvpn)" = "1" ] && {
|
||||||
|
|
|
@ -7,18 +7,19 @@ timeout=$(uci -q get openmptcprouter.settings.status_getip_timeout)
|
||||||
[ -z "$timeout" ] && timeout="1"
|
[ -z "$timeout" ] && timeout="1"
|
||||||
|
|
||||||
get_ip_from_server() {
|
get_ip_from_server() {
|
||||||
|
[ -n "$ip" ] && return
|
||||||
serverport=$(uci -q get openmptcprouter.$1.port)
|
serverport=$(uci -q get openmptcprouter.$1.port)
|
||||||
get_ip() {
|
get_ip() {
|
||||||
|
[ -n "$ip" ] && return
|
||||||
serverip=$1
|
serverip=$1
|
||||||
getip="$(curl -s -k -4 -m ${timeout} --interface $intf https://$serverip:$serverport/clienthost)"
|
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://')
|
[ -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
|
if expr "$getip" : '[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*$' >/dev/null; then
|
||||||
ip=$getip
|
ip=$getip
|
||||||
break
|
return
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
config_list_foreach $1 ip get_ip
|
config_list_foreach $1 ip get_ip
|
||||||
[ -n "$ip" ] && break
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get_ip_from_website() {
|
get_ip_from_website() {
|
||||||
|
@ -30,7 +31,6 @@ get_ip_from_website() {
|
||||||
ipset del ss_rules_dst_bypass_all $checkip > /dev/null 2>&1
|
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
|
if expr "$getip" : '[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*$' >/dev/null; then
|
||||||
ip=$getip
|
ip=$getip
|
||||||
break
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,17 +7,18 @@ timeout=$(uci -q get openmptcprouter.settings.status_getip_timeout)
|
||||||
[ -z "$timeout" ] && timeout="1"
|
[ -z "$timeout" ] && timeout="1"
|
||||||
|
|
||||||
get_ip_from_server() {
|
get_ip_from_server() {
|
||||||
|
[ -n "$ip" ] && return
|
||||||
serverport=$(uci -q get openmptcprouter.$1.port)
|
serverport=$(uci -q get openmptcprouter.$1.port)
|
||||||
get_ip() {
|
get_ip() {
|
||||||
|
[ -n "$ip" ] && return
|
||||||
getip="$(curl -s -k -6 -m ${timeout} --interface $intf https://$serverip:$serverport/clienthost)"
|
getip="$(curl -s -k -6 -m ${timeout} --interface $intf https://$serverip:$serverport/clienthost)"
|
||||||
[ -n "$getip" ] && getip=$(echo $getip | jsonfilter -e '@.client_host')
|
[ -n "$getip" ] && getip=$(echo $getip | jsonfilter -e '@.client_host')
|
||||||
if [ -n "$(echo "$getip" | grep :)" ]; then
|
if [ -n "$(echo "$getip" | grep :)" ]; then
|
||||||
ip=$getip
|
ip=$getip
|
||||||
break
|
return
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
config_list_foreach $1 ip get_ip
|
config_list_foreach $1 ip get_ip
|
||||||
[ -n "$ip" ] && break
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get_ip_from_website() {
|
get_ip_from_website() {
|
||||||
|
@ -29,7 +30,6 @@ get_ip_from_website() {
|
||||||
ipset del ss_rules6_dst_bypass_all $checkip > /dev/null 2>&1
|
ipset del ss_rules6_dst_bypass_all $checkip > /dev/null 2>&1
|
||||||
if [ -n "$(echo "$getip" | grep :)" ]; then
|
if [ -n "$(echo "$getip" | grep :)" ]; then
|
||||||
ip=$getip
|
ip=$getip
|
||||||
break
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,10 @@ timeout="$(uci -q get openmptcprouter.settings.status_vps_timeout)"
|
||||||
[ -z "$intf" ] && return
|
[ -z "$intf" ] && return
|
||||||
|
|
||||||
get_mptcp_from_server() {
|
get_mptcp_from_server() {
|
||||||
|
[ -n "$support" ] && return
|
||||||
serverport=$(uci -q get openmptcprouter.$1.port)
|
serverport=$(uci -q get openmptcprouter.$1.port)
|
||||||
get_mptcp() {
|
get_mptcp() {
|
||||||
|
[ -n "$support" ] && return
|
||||||
serverip=$1
|
serverip=$1
|
||||||
if [ "$(echo $serverip | grep :)" ]; then
|
if [ "$(echo $serverip | grep :)" ]; then
|
||||||
if [ -f /proc/sys/net/mptcp/enabled ]; then
|
if [ -f /proc/sys/net/mptcp/enabled ]; then
|
||||||
|
@ -26,11 +28,10 @@ get_mptcp_from_server() {
|
||||||
fi
|
fi
|
||||||
[ -n "$support" ] && {
|
[ -n "$support" ] && {
|
||||||
support=$(echo $support | jsonfilter -e '@.mptcp')
|
support=$(echo $support | jsonfilter -e '@.mptcp')
|
||||||
break
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
config_list_foreach $1 ip get_mptcp
|
config_list_foreach $1 ip get_mptcp
|
||||||
[ -n "$support" ] && break
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get_mptcpv0_from_website() {
|
get_mptcpv0_from_website() {
|
||||||
|
|
|
@ -43,6 +43,7 @@ _login() {
|
||||||
if [ -z "$token" ]; then
|
if [ -z "$token" ]; then
|
||||||
login_on_server() {
|
login_on_server() {
|
||||||
server=$1
|
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`
|
#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)"
|
resolve="$(resolveip -t 5 $server)"
|
||||||
valid_ip6=$(valid_subnet6 $server)
|
valid_ip6=$(valid_subnet6 $server)
|
||||||
|
@ -61,10 +62,10 @@ _login() {
|
||||||
[ -n "$auth" ] && break
|
[ -n "$auth" ] && break
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
[ -z "$auth" ] && return
|
[ -n "$auth" ] && {
|
||||||
token="$(echo "$auth" | jsonfilter -q -e '@.access_token')"
|
token="$(echo "$auth" | jsonfilter -q -e '@.access_token')"
|
||||||
uci -q set openmptcprouter.${servername}.token="$token"
|
uci -q set openmptcprouter.${servername}.token="$token"
|
||||||
[ -n "$token" ] && break
|
}
|
||||||
}
|
}
|
||||||
config_load openmptcprouter
|
config_load openmptcprouter
|
||||||
config_list_foreach ${servername} ip login_on_server
|
config_list_foreach ${servername} ip login_on_server
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
#!/bin/sh /etc/rc.common
|
#!/bin/sh /etc/rc.common
|
||||||
|
|
||||||
EXTRA_COMMANDS="backup restore"
|
EXTRA_COMMANDS="backup restore"
|
||||||
EXTRA_HELP=<<EOF
|
EXTRA_HELP=" backup Backup vnstat database
|
||||||
backup Backup vnstat database
|
|
||||||
restore Restore vnstat database
|
restore Restore vnstat database
|
||||||
EOF
|
"
|
||||||
|
|
||||||
START=50
|
START=50
|
||||||
STOP=60
|
STOP=60
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue