1
0
Fork 0
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:
suyuan 2023-12-16 18:59:19 +08:00
commit 10acdbecc1
9 changed files with 82 additions and 52 deletions

View file

@ -110,12 +110,18 @@ o.default = "1"
o.datatype = "range(1, 100)"
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.default = "4"
o.datatype = "range(1, 10)"
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.placeholder = "2"
o.default = "2"
@ -191,6 +197,12 @@ o.default = "4"
o.datatype = "range(1, 10)"
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.placeholder = "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)"
/etc/init.d/mptcp reload "$DEVICE" >/dev/null || exit 0
else
logger -t "mptcp" "Set multipath off on $DEVICE ($INTERFACE) due to $ACTION"
multipath $DEVICE off 2>&1 >/dev/null
fi

View file

@ -206,8 +206,9 @@ interface_multipath_settings() {
#echo "îface: $iface"
if [ "$(uci -q get openmptcprouter.settings.force_multipath)" != "0" ]; then
_logger -t "MPTCP" "Set $iface to $mode"
if [ "$mode" = "master" ]; then
multipath "$iface" "on"
multipath "$iface" "on"
else
multipath "$iface" "$mode"
fi
@ -428,7 +429,8 @@ set_multipath() {
exist=1
fi
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
}
done

View file

@ -1246,7 +1246,7 @@ fi
_log "Reload MPTCP config for $OMR_TRACKER_DEVICE"
/etc/init.d/mptcp reload "$OMR_TRACKER_DEVICE"
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"
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
ret=$(ping -I "${device}" \
-w "$OMR_TRACKER_TIMEOUT" \
-c 2 \
-c "$OMR_TRACKER_COUNT" \
-Q 184 \
"${host}" 2>&1
) && echo "$ret" | grep -sq "bytes from" && {
) && echo "$ret" | grep -sq " 0% packet loss" && {
if [ "$localip" = "yes" ]; then
OMR_TRACKER_LATENCY=$(echo "$ret" | cut -d "/" -s -f5 | cut -d "." -f1 | tr -d '\n')
_update_rto "$OMR_TRACKER_LATENCY"
@ -161,16 +161,17 @@ _ping() {
else
ret=$(ping -B -I "${device}" \
-w "$OMR_TRACKER_TIMEOUT" \
-c 2 \
-c "$OMR_TRACKER_COUNT" \
-Q 184 \
"${host}" 2>&1
) && echo "$ret" | grep -sq "bytes from" && {
) && echo "$ret" | grep -sq " 0% packet loss" && {
if [ "$localip" = "yes" ]; then
OMR_TRACKER_LATENCY=$(echo "$ret" | cut -d "/" -s -f5 | cut -d "." -f1 | tr -d '\n')
_update_rto "$OMR_TRACKER_LATENCY"
fi
return
}
#) && echo "$ret" | grep -sq "bytes from" && {
fi
false
}
@ -184,7 +185,7 @@ _httping() {
ret=$(httping "${host}" \
-y "${deviceip}" \
-t "$OMR_TRACKER_TIMEOUT" \
-c 1 2>&1
-c "$OMR_TRACKER_COUNT" 2>&1
) && echo "$ret" | grep -sq "1 ok" && {
if [ "$localip" = "yes" ]; then
OMR_TRACKER_LATENCY=$(echo "$ret" | cut -d "/" -s -f5 | cut -d "." -f1 | tr -d '\n')
@ -196,7 +197,7 @@ _httping() {
ret=$(httping -l "${host}" \
-y "${deviceip}" \
-t "$OMR_TRACKER_TIMEOUT" \
-c 1 2>&1
-c "$OMR_TRACKER_COUNT" 2>&1
) && echo "$ret" | grep -sq "1 ok" && {
if [ "$localip" = "yes" ]; then
OMR_TRACKER_LATENCY=$(echo "$ret" | cut -d "/" -s -f5 | cut -d "." -f1 | tr -d '\n')
@ -214,7 +215,7 @@ _dns() {
ret=$(dig @"${host}" \
-b "${deviceip}" \
+time="$OMR_TRACKER_TIMEOUT" \
+tries=1 \
+tries="$OMR_TRACKER_COUNT" \
one.one.one.one
) && echo "$ret" | grep -sq "223.5.5.5" && {
OMR_TRACKER_LATENCY=$(echo "$ret" | awk '/Query time/{print $4}')

View file

@ -1,58 +1,42 @@
config defaults 'defaults'
option enabled '1'
list hosts '4.2.2.1'
list hosts '8.8.8.8'
list hosts '80.67.169.12'
list hosts '8.8.4.4'
list hosts '9.9.9.9'
list hosts '1.0.0.1'
list hosts '114.114.115.115'
list hosts '119.29.29.29'
list hosts '182.254.116.116'
list hosts '101.226.4.6'
list hosts '218.30.118.6'
list hosts '123.125.81.6'
list hosts '140.207.198.6'
list hosts '210.2.4.8'
list hosts '114.114.114.114'
list hosts '1.2.4.8'
list hosts '223.5.5.5'
list hosts '223.6.6.6'
list hosts '80.67.169.40'
list hosts '114.114.114.114'
list hosts '1.1.1.1'
list hosts6 '2606:4700:4700::1111'
list hosts6 '2606:4700:4700::1001'
list hosts6 '2001:dc7:1000::1'
list hosts6 '2620:fe::fe'
list hosts6 '2620:fe::9'
list hosts6 '2001:4860:4860::8888'
list hosts6 '2001:4860:4860::8844'
option timeout '10'
option timeout '2'
option count '2'
option tries '3'
option interval '2'
option interval_tries '1'
option type 'ping'
option wait_test '0'
option server_http_test '0'
option restart_down '1'
option restart_down '0'
option mail_alert '0'
config proxy 'proxy'
option enabled '1'
list hosts '106.11.226.158'
list hosts '59.82.122.115'
list hosts '123.58.180.7'
list hosts '123.58.180.8'
list hosts '123.125.107.11'
list hosts '123.125.107.12'
list hosts '180.76.76.76'
list hosts '61.129.7.47'
list hosts '203.205.254.157'
list hosts '212.27.48.10'
list hosts '198.27.92.1'
list hosts '151.101.129.164'
list hosts '77.88.55.77'
list hosts '1.1.1.1'
list hosts '74.82.42.42'
list hosts '176.103.130.130'
list hosts 'baidu.com'
list hosts 'qq.com'
list hosts 'weibo.com'
list hosts 'aliyun.com'
list hosts 'taobao.com'
list hosts 'iqiyi.com'
list hosts 'youku.com'
list hosts 'douyin.com'
option timeout '10'
option tries '3'
option wait_test '0'
@ -66,4 +50,4 @@ config server 'server'
option timeout '10'
option wait_test '0'
option interval '5'
option mail_alert '0'
option mail_alert '0'

View file

@ -16,13 +16,14 @@
. /lib/functions/network.sh
_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
uci_validate_section omr-tracker "$1" "$2" \
'hosts:list(host)' \
'hosts6:list(host)' \
'timeout:uinteger' \
'count:uinteger' \
'tries:uinteger' \
'interval:uinteger' \
'interval_tries:uinteger' \
@ -35,6 +36,7 @@ _validate_section() {
[ -z "$hosts" ] && hosts=$tmp_hosts
[ -z "$hosts6" ] && hosts6=$tmp_hosts6
[ -z "$timeout" ] && timeout=$tmp_timeout
[ -z "$count" ] && count=$tmp_count
[ -z "$tries" ] && tries=$tmp_tries
[ -z "$interval" ] && interval=$tmp_interval
[ -z "$interval_tries" ] && interval_tries=$tmp_interval_tries
@ -50,7 +52,7 @@ _launch_tracker() {
loopback|lan*|if0*) return;;
esac
[ -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 "interface" "$1"
@ -75,8 +77,9 @@ _launch_tracker() {
[ -z "${hosts}" ] && [ "$type" != "none" ] && return
ifstatus=$(ifstatus "$1" | jsonfilter -q -e '@["up"]')
ifdevice=$(ifstatus "$1" | jsonfilter -q -e '@["device"]')
[ "${ifstatus}" = "false" ] && [ -z "${ifdevice}" ] && return
#[ "${ifstatus}" = "false" ] && [ -z "${ifdevice}" ] && return
[ -z "${interval_tries}" ] && interval_tries=1
[ -z "${count}" ] && count=2
procd_open_instance
# shellcheck disable=SC2086
@ -84,6 +87,7 @@ _launch_tracker() {
procd_append_param env "OMR_TRACKER_HOSTS=$hosts"
procd_append_param env "OMR_TRACKER_HOSTS6=$hosts6"
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_INTERVAL=$interval"
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
EOF
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
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..."
exit 1
}
KEY="$(echo '$auth' | jsonfilter -q -e '@.access_token')"
[ -n "$KEY" ] && {
KEY=$(echo "$auth" | jsonfilter -q -e '@.access_token')
[ -z "$KEY" ] && {
[ -z "$FASTTEST" ] && echo "No token..."
exit 1
}
@ -63,17 +63,33 @@ if [ -n "$HOST" ] && [ -n "$PORT" ] && [ -n "$USERNAME" ] && [ -n "$PASSWORD" ];
fi
if [ -n "$FASTTEST" ]; 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"
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"
fi
else
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
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
#if [ $MP ]; then
@ -83,6 +99,10 @@ if [ -n "$HOST" ] && [ -n "$PORT" ] && [ -n "$USERNAME" ] && [ -n "$PASSWORD" ];
[ -z "$FASTTEST" ] && echo "Restart SQM on $INTERFACE"
/etc/init.d/sqm start $INTERFACE 2>&1 >/dev/null
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