1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-feeds.git synced 2025-03-09 15:40:03 +00:00
This commit is contained in:
suyuan 2024-05-03 08:06:35 +08:00 committed by GitHub
commit b49b012691
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 34 additions and 26 deletions

View file

@ -131,31 +131,35 @@ if [ -f /proc/sys/net/mptcp/mptcp_enabled ]; then
printf "0x%02x" $(($(($IFF^$(($IFF&$IFF_MASK))))|$FLAG)) > $FLAG_PATH printf "0x%02x" $(($(($IFF^$(($IFF&$IFF_MASK))))|$FLAG)) > $FLAG_PATH
else else
# Remove not needed if* interfaces in MPTCP
endpoint="$(ip mptcp endpoint show)"
[ -n "$endpoint" ] && oldintfs=$(echo "${endpoint}" | grep "dev if" | awk '{ print $3 }')
[ -n "$oldintfs" ] && {
for oldintf in $oldintfs; do
ip mptcp endpoint delete id $oldintf 2>&1 >/dev/null
done
}
endpoint="$(ip mptcp endpoint show)" endpoint="$(ip mptcp endpoint show)"
if [ -n "$TYPE" ]; then
# Remove not needed if* interfaces in MPTCP
[ -n "$endpoint" ] && oldintfs=$(echo "${endpoint}" | grep "dev if" | awk '{ print $3 }')
[ -n "$oldintfs" ] && {
for oldintf in $oldintfs; do
ip mptcp endpoint delete id $oldintf 2>&1 >/dev/null
done
endpoint="$(ip mptcp endpoint show)"
}
fi
if [ -n "$endpoint" ]; then if [ -n "$endpoint" ]; then
ID=$(echo "${endpoint}" | sort | grep "dev $DEVICE " | awk '{print $3}') ID=$(echo "${endpoint}" | sort | grep "dev $DEVICE " | awk '{print $3}')
IFF=$(echo "${endpoint}" | sort | grep -m 1 -E "dev $DEVICE " | awk '{print $4; exit}') IFF=$(echo "${endpoint}" | sort | grep -m 1 -E "dev $DEVICE " | awk '{print $4; exit}')
fi fi
#IP=$(ip a show $DEVICE | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p') if [ -n "$TYPE" ]; then
if [ -f /usr/bin/jsonfilter ]; then #IP=$(ip a show $DEVICE | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p')
IP=$(ip -j a show $DEVICE scope global | jsonfilter -e '@[0].addr_info[*].local') if [ -f /usr/bin/jsonfilter ]; then
elif [ -f /usr/bin/jq ]; then IP=$(ip -j a show $DEVICE scope global | jsonfilter -e '@[0].addr_info[*].local')
IP=$(ip -j a show $DEVICE scope global | jq -r '.[0].addr_info[].local') elif [ -f /usr/bin/jq ]; then
else IP=$(ip -j a show $DEVICE scope global | jq -r '.[0].addr_info[].local')
echo "jsonfilter or jq are required" else
exit 1 echo "jsonfilter or jq are required"
exit 1
fi
[ -z "$ID" ] && [ -n "$IP" ] && [ -n "$endpoint" ] && ID=$(echo "${endpoint}" show | grep "$IP " | awk '{print $3}')
[ -n "$endpoint" ] && RMID=$(echo "${endpoint}" | grep '::ffff' | awk '{ print $3 }')
[ -n "$RMID" ] && ip mptcp endpoint delete id $RMID 2>&1 >/dev/null
fi fi
[ -z "$ID" ] && [ -n "$IP" ] && [ -n "$endpoint" ] && ID=$(echo "${endpoint}" show | grep "$IP " | awk '{print $3}')
[ -n "$endpoint" ] && RMID=$(echo "${endpoint}" | grep '::ffff' | awk '{ print $3 }')
[ -n "$RMID" ] && ip mptcp endpoint delete id $RMID 2>&1 >/dev/null
case $TYPE in case $TYPE in
"off") "off")
[ -n "$ID" ] && { [ -n "$ID" ] && {

View file

@ -723,16 +723,16 @@ default_gw=$(ip route get 1.1.1.1 | grep via | awk '{print $3}')
default_gw6=$(ip -6 route get 2606:4700:4700::1111 | grep via | awk '{print $3}') default_gw6=$(ip -6 route get 2606:4700:4700::1111 | grep via | awk '{print $3}')
#current_interface_gw=$(uci -q get "network.$OMR_TRACKER_INTERFACE.gateway") #current_interface_gw=$(uci -q get "network.$OMR_TRACKER_INTERFACE.gateway")
interface_autostart=$(ifstatus "$OMR_TRACKER_INTERFACE" 2>/dev/null | jsonfilter -q -e '@["autostart"]')
interface_up=$(ifstatus "$OMR_TRACKER_INTERFACE" 2>/dev/null | jsonfilter -q -e '@["up"]')
interface_available=$(ifstatus "$OMR_TRACKER_INTERFACE" 2>/dev/null | jsonfilter -q -e '@["available"]')
interface_pending=$(ifstatus "$OMR_TRACKER_INTERFACE" 2>/dev/null | jsonfilter -q -e '@["pending"]')
interface_error=$(ifstatus "$OMR_TRACKER_INTERFACE" 2>/dev/null | jsonfilter -q -e '@["errors"][0].code')
initcwrwnd="" initcwrwnd=""
# An interface in error will never be used in MPTCP # An interface in error will never be used in MPTCP
if [ "$OMR_TRACKER_STATUS" = "ERROR" ] || ([ "$OMR_TRACKER_INTERFACE" != "omrvpn" ] && [ "$interface_up" != "true" ]); then if [ "$OMR_TRACKER_STATUS" = "ERROR" ] || ([ "$OMR_TRACKER_INTERFACE" != "omrvpn" ] && [ "$interface_up" != "true" ]); then
interface_autostart=$(ifstatus "$OMR_TRACKER_INTERFACE" 2>/dev/null | jsonfilter -q -e '@["autostart"]')
interface_up=$(ifstatus "$OMR_TRACKER_INTERFACE" 2>/dev/null | jsonfilter -q -e '@["up"]')
interface_available=$(ifstatus "$OMR_TRACKER_INTERFACE" 2>/dev/null | jsonfilter -q -e '@["available"]')
interface_pending=$(ifstatus "$OMR_TRACKER_INTERFACE" 2>/dev/null | jsonfilter -q -e '@["pending"]')
interface_error=$(ifstatus "$OMR_TRACKER_INTERFACE" 2>/dev/null | jsonfilter -q -e '@["errors"][0].code')
#if [ "$interface_available" = "true" ] && [ -n "$OMR_TRACKER_INTERFACE" ] && ([ "$(uci -q get network.$OMR_TRACKER_INTERFACE.proto)" = "modemmanager" ] || [ "$(uci -q get network.$OMR_TRACKER_INTERFACE.proto)" = "wireguard" ]) && [ "$interface_error" != "MM_PINCODE_REQUIRED" ] && [ "$interface_error" != "MM_FAILED_REASON_SIM_MISSING" ]; then #if [ "$interface_available" = "true" ] && [ -n "$OMR_TRACKER_INTERFACE" ] && ([ "$(uci -q get network.$OMR_TRACKER_INTERFACE.proto)" = "modemmanager" ] || [ "$(uci -q get network.$OMR_TRACKER_INTERFACE.proto)" = "wireguard" ]) && [ "$interface_error" != "MM_PINCODE_REQUIRED" ] && [ "$interface_error" != "MM_FAILED_REASON_SIM_MISSING" ]; then
# _log "No answer from $OMR_TRACKER_INTERFACE ($OMR_TRACKER_DEVICE), restart interface" # _log "No answer from $OMR_TRACKER_INTERFACE ($OMR_TRACKER_DEVICE), restart interface"
# _log "Set $OMR_TRACKER_INTERFACE down" # _log "Set $OMR_TRACKER_INTERFACE down"
@ -1176,7 +1176,11 @@ if [ "$multipath_config" = "master" ]; then
#ip -6 route flush cache 2>&1 >/dev/null #ip -6 route flush cache 2>&1 >/dev/null
fi fi
if ([ -n "$OMR_TRACKER_INTERFACE" ] && [ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.lc)" = "" ]) || [ $(($(date +"%s") + $((10 + RANDOM % 31)) - $(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.lc))) -gt 3600 ] || [ "$(uci -q show openmptcprouter | grep get_config=\'1\')" != "" ] || [ "$(uci -q show openmptcprouter | grep admin_error=\'1\')" != "" ]; then if ([ -n "$OMR_TRACKER_INTERFACE" ] && [ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.lc)" = "" ]) || [ $(($(date +"%s") + $((10 + RANDOM % 31)) - $(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.lc))) -gt 3600 ] || [ "$(uci -q show openmptcprouter | grep get_config=\'1\')" != "" ] || [ "$(uci -q show openmptcprouter | grep admin_error=\'1\')" != "" ]; then
[ "$(pgrep -f openmptcprouter-vps)" = "" ] && /etc/init.d/openmptcprouter-vps restart >/dev/null 2>&1 & [ "$(pgrep -f openmptcprouter-vps)" = "" ] && {
/etc/init.d/openmptcprouter-vps restart >/dev/null 2>&1 &
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.lc=$(date +"%s")
uci -q commit openmptcprouter.$OMR_TRACKER_INTERFACE
}
fi fi
multipath_config="on" multipath_config="on"
fi fi