mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-03-09 15:40:03 +00:00
Merge branch 'test' into develop
This commit is contained in:
commit
0577c0574a
10 changed files with 209 additions and 50 deletions
|
@ -24,6 +24,8 @@ export OMR_TRACKER_DEVICE_IP
|
|||
export OMR_TRACKER_DEVICE_IP6
|
||||
export OMR_TRACKER_DEVICE_GATEWAY
|
||||
export OMR_TRACKER_DEVICE_GATEWAY6
|
||||
export OMR_TRACKER_IPV6
|
||||
export OMR_TRACKER_PROTO
|
||||
|
||||
dscp=56 # set DSCP CS7 (56) in outgoing packets
|
||||
initial_hosts="$OMR_TRACKER_HOSTS"
|
||||
|
@ -87,16 +89,45 @@ _post_tracking() {
|
|||
}
|
||||
|
||||
_ping_server() {
|
||||
local serverip=$(uci -q get openmptcprouter.$1.ip)
|
||||
local servername=$1
|
||||
local disabled=$(uci -q get openmptcprouter.$1.disabled)
|
||||
local device=$2
|
||||
if [ -n "$serverip" ] && [ -n "$device" ]; then
|
||||
_ping $serverip $device "yes"
|
||||
statusp=$?
|
||||
if $(exit $statusp); then
|
||||
serverip_ping=true
|
||||
fi
|
||||
else
|
||||
serverip_ping=false
|
||||
if [ -n "$device" ] && [ "$disabled" != "1" ]; then
|
||||
check_ping() {
|
||||
serverip=$1
|
||||
if [ -n "$serverip" ]; then
|
||||
_ping $serverip $device "yes"
|
||||
statusp=$?
|
||||
if $(exit $statusp); then
|
||||
serverip_ping=true
|
||||
break
|
||||
fi
|
||||
fi
|
||||
}
|
||||
config_load openmptcprouter
|
||||
config_list_foreach ${servername} ip check_ping
|
||||
fi
|
||||
}
|
||||
|
||||
_httping_server() {
|
||||
local servername=$1
|
||||
local disabled=$(uci -q get openmptcprouter.$1.disabled)
|
||||
local port=$(uci -q get openmptcprouter.$1.port)
|
||||
local device=$2
|
||||
if [ -n "$device" ] && [ "$disabled" != "1" ]; then
|
||||
check_ping() {
|
||||
serverip=$1
|
||||
if [ -n "$serverip" ]; then
|
||||
_httping "${serverip}:${port}" $device "yes" true
|
||||
statusp=$?
|
||||
if $(exit $statusp); then
|
||||
serverip_ping=true
|
||||
break
|
||||
fi
|
||||
fi
|
||||
}
|
||||
config_load openmptcprouter
|
||||
config_list_foreach ${servername} ip check_ping
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -138,18 +169,34 @@ _httping() {
|
|||
local host=$1
|
||||
local deviceip=$2
|
||||
local localip=$3
|
||||
ret=$(httping "${host}" \
|
||||
-y "${deviceip}" \
|
||||
-t "$OMR_TRACKER_TIMEOUT" \
|
||||
-c 1 \
|
||||
-q
|
||||
) && echo "$ret" | grep -sq "1 ok" && {
|
||||
if [ "$localip" = "yes" ]; then
|
||||
OMR_TRACKER_LATENCY=$(echo "$ret" | cut -d "/" -s -f5 | cut -d "." -f1)
|
||||
_update_rto "$OMR_TRACKER_LATENCY"
|
||||
fi
|
||||
return
|
||||
}
|
||||
local https=$4
|
||||
if [ -z "$https" ] || [ "$https" = false ]; then
|
||||
ret=$(httping "${host}" \
|
||||
-y "${deviceip}" \
|
||||
-t "$OMR_TRACKER_TIMEOUT" \
|
||||
-c 1 \
|
||||
-q
|
||||
) && echo "$ret" | grep -sq "1 ok" && {
|
||||
if [ "$localip" = "yes" ]; then
|
||||
OMR_TRACKER_LATENCY=$(echo "$ret" | cut -d "/" -s -f5 | cut -d "." -f1)
|
||||
_update_rto "$OMR_TRACKER_LATENCY"
|
||||
fi
|
||||
return
|
||||
}
|
||||
else
|
||||
ret=$(httping -l "${host}" \
|
||||
-y "${deviceip}" \
|
||||
-t "$OMR_TRACKER_TIMEOUT" \
|
||||
-c 1 \
|
||||
-q
|
||||
) && echo "$ret" | grep -sq "1 ok" && {
|
||||
if [ "$localip" = "yes" ]; then
|
||||
OMR_TRACKER_LATENCY=$(echo "$ret" | cut -d "/" -s -f5 | cut -d "." -f1)
|
||||
_update_rto "$OMR_TRACKER_LATENCY"
|
||||
fi
|
||||
return
|
||||
}
|
||||
fi
|
||||
false
|
||||
}
|
||||
|
||||
|
@ -234,6 +281,7 @@ while true; do
|
|||
OMR_TRACKER_DEVICE_GATEWAY=$(ip -4 r list dev "$OMR_TRACKER_DEVICE" | grep kernel | awk '/proto kernel/ {print $1}' | tr -d "\n")
|
||||
fi
|
||||
fi
|
||||
if [ "$OMR_TRACKER_INTERFACE_IPV6" = "1" ] || [ "$OMR_TRACKER_INTERFACE_IPV6" = "auto" ]; then
|
||||
#OMR_TRACKER_DEVICE_IP6=$(ip -6 -br addr ls dev "$OMR_TRACKER_DEVICE" | awk -F'[ /]+' '{print $3}')
|
||||
#if [ -z "$OMR_TRACKER_DEVICE_IP6" ]; then
|
||||
OMR_TRACKER_DEVICE_IP6=$(ip -6 addr show dev "$OMR_TRACKER_DEVICE" | grep -v 'inet6 f' | grep -m 1 inet | awk '{print $2}' | cut -d'/' -s -f1)
|
||||
|
@ -256,6 +304,7 @@ while true; do
|
|||
if [ -z "$OMR_TRACKER_DEVICE_GATEWAY6" ] || [ "$OMR_TRACKER_DEVICE_GATEWAY6" = "::" ]; then
|
||||
OMR_TRACKER_DEVICE_GATEWAY6=$(ubus call network.interface.$OMR_TRACKER_INTERFACE status | jsonfilter -q -l 1 -e '@.route[@.nexthop="::"].target' | tr -d "\n")
|
||||
fi
|
||||
fi
|
||||
|
||||
# execute specific tracker
|
||||
if [ -n "$OMR_TRACKER_DEVICE_IP" ] && [ -n "$OMR_TRACKER_DEVICE_GATEWAY" ]; then
|
||||
|
@ -283,6 +332,10 @@ while true; do
|
|||
config_load openmptcprouter
|
||||
config_foreach _ping_server server $OMR_TRACKER_DEVICE
|
||||
fi
|
||||
if [ "$OMR_TRACKER_TYPE" = "httping" ]; then
|
||||
config_load openmptcprouter
|
||||
config_foreach _httping_server server $OMR_TRACKER_DEVICE
|
||||
fi
|
||||
if [ "$serverip_ping" = false ] && [ -n "$OMR_TRACKER_HOST" ]; then
|
||||
OMR_TRACKER_HOST=$(resolveip -4 -t 5 $OMR_TRACKER_HOST | head -n 1 | tr -d "\n")
|
||||
if [ -n "$OMR_TRACKER_HOST" ]; then
|
||||
|
@ -366,6 +419,11 @@ while true; do
|
|||
config_load openmptcprouter
|
||||
config_foreach _ping_server server $OMR_TRACKER_DEVICE
|
||||
fi
|
||||
if [ "$OMR_TRACKER_TYPE" = "httping" ]; then
|
||||
config_load openmptcprouter
|
||||
config_foreach _httping_server server $OMR_TRACKER_DEVICE
|
||||
fi
|
||||
|
||||
if [ "$serverip_ping" = false ] && [ -n "$OMR_TRACKER_HOST6" ]; then
|
||||
OMR_TRACKER_HOST6=$(resolveip -6 -t 5 $OMR_TRACKER_HOST6 | head -n 1 | tr -d "\n")
|
||||
if [ -n "$OMR_TRACKER_HOST6" ]; then
|
||||
|
|
|
@ -19,7 +19,7 @@ _validate_section() {
|
|||
|
||||
uci_validate_section omr-tracker "$1" "$2" \
|
||||
'hosts:list(host)' \
|
||||
'hosts6:list(host6)' \
|
||||
'hosts6:list(host)' \
|
||||
'timeout:uinteger' \
|
||||
'tries:uinteger' \
|
||||
'interval:uinteger' \
|
||||
|
@ -46,7 +46,7 @@ _launch_tracker() {
|
|||
loopback|lan*|if0*) return;;
|
||||
esac
|
||||
|
||||
local hosts hosts6 timeout tries interval interval_tries options type enabled wait_test
|
||||
local hosts hosts6 timeout tries interval interval_tries options type enabled wait_test ipv6 proto
|
||||
_validate_section "defaults" "defaults"
|
||||
_validate_section "interface" "$1"
|
||||
|
||||
|
@ -59,6 +59,8 @@ _launch_tracker() {
|
|||
config_get multipath "$1" multipath
|
||||
config_get ifenabled "$1" auto
|
||||
config_get gateway "$1" gateway
|
||||
config_get ipv6 "$1" ipv6
|
||||
config_get proto "$1" proto
|
||||
|
||||
[ -z "$ifname" ] || [ -z "$multipath" ] || [ "$multipath" = "off" ] && [ "$1" != "glorytun" ] && [ "$1" != "omrvpn" ] && [ "$( uci -q get openmptcprouter.$1.multipathvpn)" != "1" ] && return
|
||||
[ "${ifenabled}" = "0" ] && return
|
||||
|
@ -79,6 +81,8 @@ _launch_tracker() {
|
|||
procd_append_param env "OMR_TRACKER_DEVICE=$ifname"
|
||||
procd_append_param env "OMR_TRACKER_DEVICE_GATEWAY=$gateway"
|
||||
procd_append_param env "OMR_TRACKER_TYPE=$type"
|
||||
procd_append_param env "OMR_TRACKER_IPV6=$ipv6"
|
||||
procd_append_param env "OMR_TRACKER_PROTO=$proto"
|
||||
procd_append_param env "OMR_TRACKER_WAIT_TEST=$wait_test"
|
||||
procd_set_param limits nofile="51200 51200"
|
||||
procd_set_param respawn 0 10 0
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue