mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-02-13 11:01:50 +00:00
65 lines
2 KiB
Bash
Executable file
65 lines
2 KiB
Bash
Executable file
#!/bin/sh
|
|
. /lib/functions.sh
|
|
|
|
intf=$1
|
|
timeout="$(uci -q get openmptcprouter.settings.status_vps_timeout)"
|
|
[ -z "$timeout" ] && timeout="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 ${timeout} --interface $intf https://[$serverip]:$serverport/mptcpsupport)"
|
|
else
|
|
support="$(curl -s -k -4 -m ${timeout} --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 ${timeout} --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 ${timeout} --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
|