mirror of
				https://github.com/Ysurac/openmptcprouter-feeds.git
				synced 2025-03-09 15:40:03 +00:00 
			
		
		
		
	sync (#392)
This commit is contained in:
		
						commit
						c722aeb2bb
					
				
					 9 changed files with 68 additions and 22 deletions
				
			
		| 
						 | 
				
			
			@ -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"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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 "1.1.1.1" && {
 | 
			
		||||
		OMR_TRACKER_LATENCY=$(echo "$ret" | awk '/Query time/{print $4}')
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -18,6 +18,7 @@ config defaults 'defaults'
 | 
			
		|||
        list hosts6 '2001:4860:4860::8888'
 | 
			
		||||
        list hosts6 '2001:4860:4860::8844'
 | 
			
		||||
        option timeout '2'
 | 
			
		||||
        option count '2'
 | 
			
		||||
        option tries '3'
 | 
			
		||||
        option interval '2'
 | 
			
		||||
        option interval_tries '1'
 | 
			
		||||
| 
						 | 
				
			
			@ -29,7 +30,6 @@ config defaults 'defaults'
 | 
			
		|||
 | 
			
		||||
config proxy 'proxy'
 | 
			
		||||
	option enabled '1'
 | 
			
		||||
	list hosts '1.0.0.1'
 | 
			
		||||
	list hosts '212.27.48.10'
 | 
			
		||||
	list hosts '198.27.92.1'
 | 
			
		||||
	list hosts '151.101.129.164'
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue