mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-02-13 02:51:50 +00:00
Use server script to detect if MPTCP is enabled on interface
This commit is contained in:
parent
fa375333df
commit
d36d5c7f65
2 changed files with 66 additions and 4 deletions
|
@ -1,5 +1,63 @@
|
|||
#!/bin/sh
|
||||
multipathip=$(dig +short A multipath-tcp.org | tr -d "\n")
|
||||
ipset add ss_rules_dst_bypass_all $multipathip > /dev/null 2>&1
|
||||
curl -s -4 -m 2 --interface $1 http://www.multipath-tcp.org
|
||||
ipset del ss_rules_dst_bypass_all $multipathip > /dev/null 2>&1
|
||||
. /lib/functions.sh
|
||||
|
||||
intf=$1
|
||||
|
||||
[ -z "$intf" ] && return
|
||||
|
||||
get_mptcp_from_server() {
|
||||
serverport=$(uci -q get openmptcprouter.$1.port)
|
||||
get_mptcp() {
|
||||
serverip=$1
|
||||
if [ "$(echo $serverip | grep :)" ]; then
|
||||
support="$(curl -s -k -6 -m 2 --interface $intf https://[$serverip]:$serverport/mptcpsupport)"
|
||||
else
|
||||
support="$(curl -s -k -4 -m 2 --interface $intf https://$serverip:$serverport/mptcpsupport)"
|
||||
fi
|
||||
[ -n "$support" ] && {
|
||||
support=$(echo $support | jsonfilter -e '@.mptcp')
|
||||
break
|
||||
}
|
||||
}
|
||||
config_list_foreach $1 ip get_mptcp
|
||||
[ -n "$support" ] && break
|
||||
}
|
||||
|
||||
get_mptcp_from_website() {
|
||||
multipathip=$(dig +short A multipath-tcp.org | tr -d "\n")
|
||||
ipset add ss_rules_dst_bypass_all $multipathip > /dev/null 2>&1
|
||||
support="$(curl -s -4 -m 2 --interface $intf http://www.multipath-tcp.org)"
|
||||
ipset del ss_rules_dst_bypass_all $multipathip > /dev/null 2>&1
|
||||
[ -n "$support" ] && {
|
||||
if [ "$support" = "Yay, you are MPTCP-capable! You can now rest in peace." ]; then
|
||||
support="working"
|
||||
else
|
||||
support="not working"
|
||||
fi
|
||||
}
|
||||
}
|
||||
|
||||
get_mptcp_from_website6() {
|
||||
multipathip=$(dig +short AAAA multipath-tcp.org | tr -d "\n")
|
||||
ipset add ss_rules6_dst_bypass_all $multipathip > /dev/null 2>&1
|
||||
support="$(curl -s -6 -m 2 --interface $intf http://www.multipath-tcp.org)"
|
||||
ipset del ss_rules6_dst_bypass_all $multipathip > /dev/null 2>&1
|
||||
[ -n "$support" ] && {
|
||||
if [ "$support" = "Yay, you are MPTCP-capable! You can now rest in peace." ]; then
|
||||
support="working"
|
||||
else
|
||||
support="not working"
|
||||
fi
|
||||
}
|
||||
}
|
||||
|
||||
support=""
|
||||
config_load openmptcprouter
|
||||
config_foreach get_mptcp_from_server server
|
||||
[ -z "$support" ] && [ -n "$(ip -4 a show dev $intf)" ] && get_mptcp_from_website
|
||||
[ -z "$support" ] && [ -n "$(ip -6 a show dev $intf)" ] && get_mptcp_from_website6
|
||||
if [ "$support" = "working" ]; then
|
||||
echo "MPTCP enabled"
|
||||
elif [ "$support" = "not working" ]; then
|
||||
echo "MPTCP disabled"
|
||||
fi
|
||||
|
|
|
@ -1108,6 +1108,10 @@ if [ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.lc)" = "" ] || [ $(($(
|
|||
}
|
||||
config_load openmptcprouter
|
||||
config_foreach traceboxmtutest server
|
||||
[ "$(uci -q get openmptcprouter.settings.tracebox)" = "0" ] && {
|
||||
mptcpsupport="$(omr-mptcp-intf $OMR_TRACKER_DEVICE)"
|
||||
[ -n "$mptcpsupport" ] && uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.mptcp_status="$mptcpsupport"
|
||||
}
|
||||
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.state='up'
|
||||
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.lc=$(date +"%s")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue