1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-feeds.git synced 2025-02-15 03:51:51 +00:00
This commit is contained in:
suyuan 2023-12-16 18:58:20 +08:00 committed by GitHub
commit c722aeb2bb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 68 additions and 22 deletions

View file

@ -110,12 +110,18 @@ o.default = "1"
o.datatype = "range(1, 100)" o.datatype = "range(1, 100)"
o.rmempty = false o.rmempty = false
o = s:option(Value, "tries", translate("Tries")) o = s:option(Value, "tries", translate("Tries"), translate("How many times repeat test"))
o.placeholder = "4" o.placeholder = "4"
o.default = "4" o.default = "4"
o.datatype = "range(1, 10)" o.datatype = "range(1, 10)"
o.rmempty = false o.rmempty = false
o = s:option(Value, "count", translate("Count"), translate("How many packets send on each test"))
o.placeholder = "2"
o.default = "2"
o.datatype = "range(1, 100)"
o.rmempty = false
o = s:option(Value, "interval", translate("Retry interval (s)")) o = s:option(Value, "interval", translate("Retry interval (s)"))
o.placeholder = "2" o.placeholder = "2"
o.default = "2" o.default = "2"
@ -191,6 +197,12 @@ o.default = "4"
o.datatype = "range(1, 10)" o.datatype = "range(1, 10)"
o.rmempty = false o.rmempty = false
o = s:option(Value, "count", translate("Count"), translate("How many packets send on each test, one wrong make test fail, one wrong make tail fail"))
o.placeholder = "2"
o.default = "2"
o.datatype = "range(1, 100)"
o.rmempty = false
o = s:option(Value, "interval", translate("Retry interval (s)")) o = s:option(Value, "interval", translate("Retry interval (s)"))
o.placeholder = "2" o.placeholder = "2"
o.default = "2" o.default = "2"

View file

@ -10,6 +10,7 @@ if [ "$ACTION" = ifup -o "$ACTION" = ifupdate -o "$ACTION" = iflink ] && [ -z "$
logger -t "mptcp" "Reloading mptcp config due to $ACTION of $INTERFACE ($DEVICE)" logger -t "mptcp" "Reloading mptcp config due to $ACTION of $INTERFACE ($DEVICE)"
/etc/init.d/mptcp reload "$DEVICE" >/dev/null || exit 0 /etc/init.d/mptcp reload "$DEVICE" >/dev/null || exit 0
else else
logger -t "mptcp" "Set multipath off on $DEVICE ($INTERFACE) due to $ACTION"
multipath $DEVICE off 2>&1 >/dev/null multipath $DEVICE off 2>&1 >/dev/null
fi fi

View file

@ -206,8 +206,9 @@ interface_multipath_settings() {
#echo "îface: $iface" #echo "îface: $iface"
if [ "$(uci -q get openmptcprouter.settings.force_multipath)" != "0" ]; then if [ "$(uci -q get openmptcprouter.settings.force_multipath)" != "0" ]; then
_logger -t "MPTCP" "Set $iface to $mode"
if [ "$mode" = "master" ]; then if [ "$mode" = "master" ]; then
multipath "$iface" "on" multipath "$iface" "on"
else else
multipath "$iface" "$mode" multipath "$iface" "$mode"
fi fi
@ -428,7 +429,8 @@ set_multipath() {
exist=1 exist=1
fi fi
done done
[ "$exist" = "0" ] && { [ "$exist" = "0" ] && [ -z "$(multipath $iface | grep deactivated)" ] && {
logger -t "MPTCP" "Disabling MPTCP on interface $iface not found in enabled multipath list"
multipath $iface off multipath $iface off
} }
done done

View file

@ -1246,7 +1246,7 @@ fi
_log "Reload MPTCP config for $OMR_TRACKER_DEVICE" _log "Reload MPTCP config for $OMR_TRACKER_DEVICE"
/etc/init.d/mptcp reload "$OMR_TRACKER_DEVICE" /etc/init.d/mptcp reload "$OMR_TRACKER_DEVICE"
fi fi
_log "Multipath $OMR_TRACKER_DEVICE switched to $multipath_config (from $multipath_status)" _log "Multipath $OMR_TRACKER_DEVICE ($OMR_TRACKER_INTERFACE) switched to $multipath_config (from $multipath_status)"
multipath "$OMR_TRACKER_DEVICE" "$multipath_config" multipath "$OMR_TRACKER_DEVICE" "$multipath_config"
fi fi
} }

View file

@ -148,10 +148,10 @@ _ping() {
if [ -n "$OMR_TRACKER_INTERFACE" ] && ([ "$(uci -q get network.$OMR_TRACKER_INTERFACE.proto)" = "3g" ] || [ "$(uci -q get network.$OMR_TRACKER_INTERFACE.proto)" = "qmi" ] || [ "$(uci -q get network.$OMR_TRACKER_INTERFACE.proto)" = "ncm" ]); then if [ -n "$OMR_TRACKER_INTERFACE" ] && ([ "$(uci -q get network.$OMR_TRACKER_INTERFACE.proto)" = "3g" ] || [ "$(uci -q get network.$OMR_TRACKER_INTERFACE.proto)" = "qmi" ] || [ "$(uci -q get network.$OMR_TRACKER_INTERFACE.proto)" = "ncm" ]); then
ret=$(ping -I "${device}" \ ret=$(ping -I "${device}" \
-w "$OMR_TRACKER_TIMEOUT" \ -w "$OMR_TRACKER_TIMEOUT" \
-c 2 \ -c "$OMR_TRACKER_COUNT" \
-Q 184 \ -Q 184 \
"${host}" 2>&1 "${host}" 2>&1
) && echo "$ret" | grep -sq "bytes from" && { ) && echo "$ret" | grep -sq " 0% packet loss" && {
if [ "$localip" = "yes" ]; then if [ "$localip" = "yes" ]; then
OMR_TRACKER_LATENCY=$(echo "$ret" | cut -d "/" -s -f5 | cut -d "." -f1 | tr -d '\n') OMR_TRACKER_LATENCY=$(echo "$ret" | cut -d "/" -s -f5 | cut -d "." -f1 | tr -d '\n')
_update_rto "$OMR_TRACKER_LATENCY" _update_rto "$OMR_TRACKER_LATENCY"
@ -161,16 +161,17 @@ _ping() {
else else
ret=$(ping -B -I "${device}" \ ret=$(ping -B -I "${device}" \
-w "$OMR_TRACKER_TIMEOUT" \ -w "$OMR_TRACKER_TIMEOUT" \
-c 2 \ -c "$OMR_TRACKER_COUNT" \
-Q 184 \ -Q 184 \
"${host}" 2>&1 "${host}" 2>&1
) && echo "$ret" | grep -sq "bytes from" && { ) && echo "$ret" | grep -sq " 0% packet loss" && {
if [ "$localip" = "yes" ]; then if [ "$localip" = "yes" ]; then
OMR_TRACKER_LATENCY=$(echo "$ret" | cut -d "/" -s -f5 | cut -d "." -f1 | tr -d '\n') OMR_TRACKER_LATENCY=$(echo "$ret" | cut -d "/" -s -f5 | cut -d "." -f1 | tr -d '\n')
_update_rto "$OMR_TRACKER_LATENCY" _update_rto "$OMR_TRACKER_LATENCY"
fi fi
return return
} }
#) && echo "$ret" | grep -sq "bytes from" && {
fi fi
false false
} }
@ -184,7 +185,7 @@ _httping() {
ret=$(httping "${host}" \ ret=$(httping "${host}" \
-y "${deviceip}" \ -y "${deviceip}" \
-t "$OMR_TRACKER_TIMEOUT" \ -t "$OMR_TRACKER_TIMEOUT" \
-c 1 2>&1 -c "$OMR_TRACKER_COUNT" 2>&1
) && echo "$ret" | grep -sq "1 ok" && { ) && echo "$ret" | grep -sq "1 ok" && {
if [ "$localip" = "yes" ]; then if [ "$localip" = "yes" ]; then
OMR_TRACKER_LATENCY=$(echo "$ret" | cut -d "/" -s -f5 | cut -d "." -f1 | tr -d '\n') OMR_TRACKER_LATENCY=$(echo "$ret" | cut -d "/" -s -f5 | cut -d "." -f1 | tr -d '\n')
@ -196,7 +197,7 @@ _httping() {
ret=$(httping -l "${host}" \ ret=$(httping -l "${host}" \
-y "${deviceip}" \ -y "${deviceip}" \
-t "$OMR_TRACKER_TIMEOUT" \ -t "$OMR_TRACKER_TIMEOUT" \
-c 1 2>&1 -c "$OMR_TRACKER_COUNT" 2>&1
) && echo "$ret" | grep -sq "1 ok" && { ) && echo "$ret" | grep -sq "1 ok" && {
if [ "$localip" = "yes" ]; then if [ "$localip" = "yes" ]; then
OMR_TRACKER_LATENCY=$(echo "$ret" | cut -d "/" -s -f5 | cut -d "." -f1 | tr -d '\n') OMR_TRACKER_LATENCY=$(echo "$ret" | cut -d "/" -s -f5 | cut -d "." -f1 | tr -d '\n')
@ -214,7 +215,7 @@ _dns() {
ret=$(dig @"${host}" \ ret=$(dig @"${host}" \
-b "${deviceip}" \ -b "${deviceip}" \
+time="$OMR_TRACKER_TIMEOUT" \ +time="$OMR_TRACKER_TIMEOUT" \
+tries=1 \ +tries="$OMR_TRACKER_COUNT" \
one.one.one.one one.one.one.one
) && echo "$ret" | grep -sq "1.1.1.1" && { ) && echo "$ret" | grep -sq "1.1.1.1" && {
OMR_TRACKER_LATENCY=$(echo "$ret" | awk '/Query time/{print $4}') OMR_TRACKER_LATENCY=$(echo "$ret" | awk '/Query time/{print $4}')

View file

@ -18,6 +18,7 @@ config defaults 'defaults'
list hosts6 '2001:4860:4860::8888' list hosts6 '2001:4860:4860::8888'
list hosts6 '2001:4860:4860::8844' list hosts6 '2001:4860:4860::8844'
option timeout '2' option timeout '2'
option count '2'
option tries '3' option tries '3'
option interval '2' option interval '2'
option interval_tries '1' option interval_tries '1'
@ -29,7 +30,6 @@ config defaults 'defaults'
config proxy 'proxy' config proxy 'proxy'
option enabled '1' option enabled '1'
list hosts '1.0.0.1'
list hosts '212.27.48.10' list hosts '212.27.48.10'
list hosts '198.27.92.1' list hosts '198.27.92.1'
list hosts '151.101.129.164' list hosts '151.101.129.164'

View file

@ -16,13 +16,14 @@
. /lib/functions/network.sh . /lib/functions/network.sh
_validate_section() { _validate_section() {
local tmp_hosts=$hosts tmp_hosts6=$hosts6 tmp_timeout=$timeout tmp_tries=$tries local tmp_hosts=$hosts tmp_hosts6=$hosts6 tmp_timeout=$timeout tmp_count=$count tmp_tries=$tries
local tmp_interval=$interval tmp_interval_tries=$interval_tries tmp_options=$options tmp_type=$type tmp_enabled=$enabled tmp_wait_test=$wait_test tmp_server_http_test=$server_http_test local tmp_interval=$interval tmp_interval_tries=$interval_tries tmp_options=$options tmp_type=$type tmp_enabled=$enabled tmp_wait_test=$wait_test tmp_server_http_test=$server_http_test
uci_validate_section omr-tracker "$1" "$2" \ uci_validate_section omr-tracker "$1" "$2" \
'hosts:list(host)' \ 'hosts:list(host)' \
'hosts6:list(host)' \ 'hosts6:list(host)' \
'timeout:uinteger' \ 'timeout:uinteger' \
'count:uinteger' \
'tries:uinteger' \ 'tries:uinteger' \
'interval:uinteger' \ 'interval:uinteger' \
'interval_tries:uinteger' \ 'interval_tries:uinteger' \
@ -35,6 +36,7 @@ _validate_section() {
[ -z "$hosts" ] && hosts=$tmp_hosts [ -z "$hosts" ] && hosts=$tmp_hosts
[ -z "$hosts6" ] && hosts6=$tmp_hosts6 [ -z "$hosts6" ] && hosts6=$tmp_hosts6
[ -z "$timeout" ] && timeout=$tmp_timeout [ -z "$timeout" ] && timeout=$tmp_timeout
[ -z "$count" ] && count=$tmp_count
[ -z "$tries" ] && tries=$tmp_tries [ -z "$tries" ] && tries=$tmp_tries
[ -z "$interval" ] && interval=$tmp_interval [ -z "$interval" ] && interval=$tmp_interval
[ -z "$interval_tries" ] && interval_tries=$tmp_interval_tries [ -z "$interval_tries" ] && interval_tries=$tmp_interval_tries
@ -50,7 +52,7 @@ _launch_tracker() {
loopback|lan*|if0*) return;; loopback|lan*|if0*) return;;
esac esac
[ -z "$1" ] && return [ -z "$1" ] && return
local hosts hosts6 timeout tries interval interval_tries options type enabled wait_test ipv6 proto server_http_test local hosts hosts6 timeout count tries interval interval_tries options type enabled wait_test ipv6 proto server_http_test
_validate_section "defaults" "defaults" _validate_section "defaults" "defaults"
_validate_section "interface" "$1" _validate_section "interface" "$1"
@ -75,8 +77,9 @@ _launch_tracker() {
[ -z "${hosts}" ] && [ "$type" != "none" ] && return [ -z "${hosts}" ] && [ "$type" != "none" ] && return
ifstatus=$(ifstatus "$1" | jsonfilter -q -e '@["up"]') ifstatus=$(ifstatus "$1" | jsonfilter -q -e '@["up"]')
ifdevice=$(ifstatus "$1" | jsonfilter -q -e '@["device"]') ifdevice=$(ifstatus "$1" | jsonfilter -q -e '@["device"]')
[ "${ifstatus}" = "false" ] && [ -z "${ifdevice}" ] && return #[ "${ifstatus}" = "false" ] && [ -z "${ifdevice}" ] && return
[ -z "${interval_tries}" ] && interval_tries=1 [ -z "${interval_tries}" ] && interval_tries=1
[ -z "${count}" ] && count=2
procd_open_instance procd_open_instance
# shellcheck disable=SC2086 # shellcheck disable=SC2086
@ -84,6 +87,7 @@ _launch_tracker() {
procd_append_param env "OMR_TRACKER_HOSTS=$hosts" procd_append_param env "OMR_TRACKER_HOSTS=$hosts"
procd_append_param env "OMR_TRACKER_HOSTS6=$hosts6" procd_append_param env "OMR_TRACKER_HOSTS6=$hosts6"
procd_append_param env "OMR_TRACKER_TIMEOUT=$timeout" procd_append_param env "OMR_TRACKER_TIMEOUT=$timeout"
procd_append_param env "OMR_TRACKER_COUNT=$count"
procd_append_param env "OMR_TRACKER_TRIES=$tries" procd_append_param env "OMR_TRACKER_TRIES=$tries"
procd_append_param env "OMR_TRACKER_INTERVAL=$interval" procd_append_param env "OMR_TRACKER_INTERVAL=$interval"
procd_append_param env "OMR_TRACKER_INTERVAL_TRIES=$interval_tries" procd_append_param env "OMR_TRACKER_INTERVAL_TRIES=$interval_tries"

View file

@ -64,6 +64,12 @@ if [ "$(uci -q get omr-tracker.proxy.hosts | grep '176.103.130.130')" != "" ]; t
commit omr-tracker commit omr-tracker
EOF EOF
fi fi
if [ "$(uci -q get omr-tracker.proxy.hosts | grep '1.0.0.1')" != "" ]; then
uci -q batch <<-EOF >/dev/null
del_list omr-tracker.proxy.hosts='1.0.0.1'
commit omr-tracker
EOF
fi
if [ "$(uci -q get omr-tracker.proxy.hosts | grep '198.41.212.162')" = "" ]; then if [ "$(uci -q get omr-tracker.proxy.hosts | grep '198.41.212.162')" = "" ]; then
uci -q batch <<-EOF >/dev/null uci -q batch <<-EOF >/dev/null

View file

@ -27,8 +27,8 @@ if [ -n "$HOST" ] && [ -n "$PORT" ] && [ -n "$USERNAME" ] && [ -n "$PASSWORD" ];
[ -z "$FASTTEST" ] && echo "No answer to API request..." [ -z "$FASTTEST" ] && echo "No answer to API request..."
exit 1 exit 1
} }
KEY="$(echo '$auth' | jsonfilter -q -e '@.access_token')" KEY=$(echo "$auth" | jsonfilter -q -e '@.access_token')
[ -n "$KEY" ] && { [ -z "$KEY" ] && {
[ -z "$FASTTEST" ] && echo "No token..." [ -z "$FASTTEST" ] && echo "No token..."
exit 1 exit 1
} }
@ -63,17 +63,33 @@ if [ -n "$HOST" ] && [ -n "$PORT" ] && [ -n "$USERNAME" ] && [ -n "$PASSWORD" ];
fi fi
if [ -n "$FASTTEST" ]; then if [ -n "$FASTTEST" ]; then
if [ -n "$UPLOAD" ]; then if [ -n "$UPLOAD" ]; then
avg_speed=$(curl -k --max-time 30 -o /dev/null -qfsS -w '%{speed_upload}' -X POST -d @${upload_file} -d @${upload_file} --interface $INTERFACE -H "Authorization: Bearer ${KEY}" https://${HOST}:${PORT}/speedtest 2>/dev/null) if [ "$resolve" != "${HOST}" ] || [ "$valid_ip6" != "ok" ]; then
avg_speed=$(curl -k --max-time 30 -o /dev/null -qfsS -w '%{speed_upload}' -X POST -d @${upload_file} -d @${upload_file} --interface $INTERFACE -H "Authorization: Bearer ${KEY}" https://${HOST}:${PORT}/speedtest 2>/dev/null)
else
avg_speed=$(curl -k --max-time 30 -o /dev/null -qfsS -w '%{speed_upload}' -X POST -d @${upload_file} -d @${upload_file} --interface $INTERFACE -H "Authorization: Bearer ${KEY}" https://[${HOST}]:${PORT}/speedtest 2>/dev/null)
fi
echo -n "$avg_speed" echo -n "$avg_speed"
else else
avg_speed=$(curl -k --max-time 30 -o /dev/null -qfsS -w '%{speed_download}' --interface $INTERFACE -H "Authorization: Bearer ${KEY}" https://${HOST}:${PORT}/speedtest 2>/dev/null) if [ "$resolve" != "${HOST}" ] || [ "$valid_ip6" != "ok" ]; then
avg_speed=$(curl -k --max-time 30 -o /dev/null -qfsS -w '%{speed_download}' --interface $INTERFACE -H "Authorization: Bearer ${KEY}" https://${HOST}:${PORT}/speedtest 2>/dev/null)
else
avg_speed=$(curl -k --max-time 30 -o /dev/null -qfsS -w '%{speed_download}' --interface $INTERFACE -H "Authorization: Bearer ${KEY}" https://[${HOST}]:${PORT}/speedtest 2>/dev/null)
fi
echo -n "$avg_speed" echo -n "$avg_speed"
fi fi
else else
if [ -n "$UPLOAD" ]; then if [ -n "$UPLOAD" ]; then
curl -k -o /dev/null -X POST -d @${upload_file} -d @${upload_file} --interface $INTERFACE -H "Authorization: Bearer ${KEY}" https://${HOST}:${PORT}/speedtest || echo if [ "$resolve" != "${HOST}" ] || [ "$valid_ip6" != "ok" ]; then
curl -k -o /dev/null -X POST -d @${upload_file} -d @${upload_file} --interface $INTERFACE -H "Authorization: Bearer ${KEY}" https://${HOST}:${PORT}/speedtest || echo
else
curl -k -o /dev/null -X POST -d @${upload_file} -d @${upload_file} --interface $INTERFACE -H "Authorization: Bearer ${KEY}" https://[${HOST}]:${PORT}/speedtest || echo
fi
else else
curl -k -o /dev/null --interface $INTERFACE -H "Authorization: Bearer ${KEY}" https://${HOST}:${PORT}/speedtest || echo if [ "$resolve" != "${HOST}" ] || [ "$valid_ip6" != "ok" ]; then
curl -k -o /dev/null --interface $INTERFACE -H "Authorization: Bearer ${KEY}" https://${HOST}:${PORT}/speedtest || echo
else
curl -k -o /dev/null --interface $INTERFACE -H "Authorization: Bearer ${KEY}" https://[${HOST}]:${PORT}/speedtest || echo
fi
fi fi
fi fi
#if [ $MP ]; then #if [ $MP ]; then
@ -83,6 +99,10 @@ if [ -n "$HOST" ] && [ -n "$PORT" ] && [ -n "$USERNAME" ] && [ -n "$PASSWORD" ];
[ -z "$FASTTEST" ] && echo "Restart SQM on $INTERFACE" [ -z "$FASTTEST" ] && echo "Restart SQM on $INTERFACE"
/etc/init.d/sqm start $INTERFACE 2>&1 >/dev/null /etc/init.d/sqm start $INTERFACE 2>&1 >/dev/null
else else
curl -k -o /dev/null -H "Authorization: Bearer ${KEY}" https://${HOST}:${PORT}/speedtest || echo if [ "$resolve" != "${HOST}" ] || [ "$valid_ip6" != "ok" ]; then
curl -k -o /dev/null -H "Authorization: Bearer ${KEY}" https://${HOST}:${PORT}/speedtest || echo
else
curl -k -o /dev/null -H "Authorization: Bearer ${KEY}" https://[${HOST}]:${PORT}/speedtest || echo
fi
fi fi
fi fi