mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-02-13 02:51:50 +00:00
Fix and more info on omr-tracker
This commit is contained in:
parent
cebb8eb9d7
commit
0c41334fc0
2 changed files with 60 additions and 39 deletions
|
@ -115,7 +115,11 @@ default_gw=$(ip route show default | grep -v metric | awk '/default/ {print $3}'
|
|||
if [ "$OMR_TRACKER_STATUS" = "ERROR" ]; then
|
||||
if [ -d "/sys/class/net/$OMR_TRACKER_DEVICE" ]; then
|
||||
[ "$multipath_status" = "off" ] || {
|
||||
if [ "$OMR_TRACKER_STATUS_MSG" = "" ]; then
|
||||
_log "$OMR_TRACKER_DEVICE switched off"
|
||||
else
|
||||
_log "$OMR_TRACKER_DEVICE switched off because $OMR_TRACKER_STATUS_MSG"
|
||||
fi
|
||||
if [ "$(sysctl -n net.mptcp.mptcp_enabled | tr -d '\n')" = "1" ]; then
|
||||
multipath "$OMR_TRACKER_DEVICE" off
|
||||
fi
|
||||
|
@ -136,7 +140,11 @@ if [ "$OMR_TRACKER_STATUS" = "ERROR" ]; then
|
|||
config_foreach set_route interface $OMR_TRACKER_INTERFACE
|
||||
fi
|
||||
if [ "$OMR_TRACKER_INTERFACE" = "glorytun" ] || [ "$OMR_TRACKER_INTERFACE" = "omrvpn" ]; then
|
||||
if [ "$OMR_TRACKER_STATUS_MSG" = "" ]; then
|
||||
_log "$OMR_TRACKER_INTERFACE down"
|
||||
else
|
||||
_log "$OMR_TRACKER_INTERFACE down because $OMR_TRACKER_STATUS_MSG"
|
||||
fi
|
||||
config_load network
|
||||
config_foreach set_route interface $OMR_TRACKER_INTERFACE
|
||||
#config_load shadowsocks-libev
|
||||
|
|
|
@ -141,6 +141,7 @@ while true; do
|
|||
OMR_TRACKER_STATUS_MSG=""
|
||||
OMR_TRACKER_LATENCY=
|
||||
OMR_TRACKER_TIMEOUT=$((rto / 1000 + (rto % 1000 ? 1 : 0)))
|
||||
OMT_TRACKER_LIST_HOSTS=""
|
||||
|
||||
if [ -d "/sys/class/net/$OMR_TRACKER_DEVICE" ]; then
|
||||
# retrieve iface ip and gateway
|
||||
|
@ -164,16 +165,20 @@ while true; do
|
|||
|
||||
# execute specific tracker
|
||||
if [ -n "$OMR_TRACKER_DEVICE_IP" ] && [ -n "$OMR_TRACKER_DEVICE_GATEWAY" ]; then
|
||||
_ping "$OMR_TRACKER_DEVICE_GATEWAY" "$OMR_TRACKER_DEVICE_IP" "no"
|
||||
status=$?
|
||||
if $(exit $status); then
|
||||
if [ "$OMR_TRACKER_TYPE" = "none" ]; then
|
||||
OMR_TRACKER_STATUS="OK"
|
||||
else
|
||||
# setup loop variable
|
||||
tries="$OMR_TRACKER_TRIES"
|
||||
# loop until tries attempts have been reached
|
||||
while [ "$tries" -gt 0 ]; do
|
||||
_ping "$OMR_TRACKER_DEVICE_GATEWAY" "$OMR_TRACKER_DEVICE_IP" "no"
|
||||
status=$?
|
||||
if $(exit $status) && [ "$OMR_TRACKER_TYPE" = "none" ]; then
|
||||
OMR_TRACKER_STATUS_MSG=""
|
||||
OMR_TRACKER_STATUS="OK"
|
||||
break
|
||||
else
|
||||
if $(exit $status); then
|
||||
OMR_TRACKER_STATUS_MSG="gateway down"
|
||||
fi
|
||||
# Check if route is not used
|
||||
while ! ip route add $OMR_TRACKER_HOST via $OMR_TRACKER_DEVICE_GATEWAY dev $OMR_TRACKER_DEVICE src $OMR_TRACKER_DEVICE_IP > /dev/null 2&>1
|
||||
do
|
||||
|
@ -182,31 +187,39 @@ while true; do
|
|||
done
|
||||
if [ "$OMR_TRACKER_TYPE" = "ping" ]; then
|
||||
_ping "$OMR_TRACKER_HOST" "$OMR_TRACKER_DEVICE_IP" "yes"
|
||||
status=$?
|
||||
statusb=$?
|
||||
elif [ "$OMR_TRACKER_TYPE" = "httping" ]; then
|
||||
_httping "$OMR_TRACKER_HOST" "$OMR_TRACKER_DEVICE_IP" "yes"
|
||||
status=$?
|
||||
statusb=$?
|
||||
elif [ "$OMR_TRACKER_TYPE" = "dns" ]; then
|
||||
_dns "$OMR_TRACKER_HOST" "$OMR_TRACKER_DEVICE_IP" "yes"
|
||||
status=$?
|
||||
statusb=$?
|
||||
fi
|
||||
ip route del "$OMR_TRACKER_HOST" via "$OMR_TRACKER_DEVICE_GATEWAY" dev "$OMR_TRACKER_DEVICE" src "$OMR_TRACKER_DEVICE_IP" > /dev/null 2&>1
|
||||
if $(exit $status); then
|
||||
if $(exit $statusb); then
|
||||
OMR_TRACKER_STATUS_MSG=""
|
||||
OMR_TRACKER_STATUS="OK"
|
||||
break
|
||||
else
|
||||
OMR_TRACKER_STATUS_MSG="$OMR_TRACKER_TYPE to $OMR_TRACKER_HOST from $OMR_TRACKER_DEVICE_IP error"
|
||||
if [ "$OMR_TRACKER_LIST_HOSTS" = "" ]; then
|
||||
OMR_TRACKER_LIST_HOSTS="$OMR_TRACKER_HOST"
|
||||
else
|
||||
OMR_TRACKER_LIST_HOSTS="$OMR_TRACKER_LIST_HOSTS,$OMR_TRACKER_HOST"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
tries=$((tries - 1))
|
||||
OMR_TRACKER_TIMEOUT=$((OMR_TRACKER_TIMEOUT * 2))
|
||||
sleep 1
|
||||
#OMR_TRACKER_TIMEOUT=$((OMR_TRACKER_TIMEOUT * 2))
|
||||
_restart
|
||||
done
|
||||
fi
|
||||
else
|
||||
OMR_TRACKER_STATUS_MSG="gateway down"
|
||||
fi
|
||||
|
||||
if [ "$OMR_TRACKER_LIST_HOSTS" != "" ]; then
|
||||
if [ "$OMR_TRACKER_STATUS_MSG" = "" ]; then
|
||||
OMR_TRACKER_STATUS_MSG="$OMR_TRACKER_TYPE from $OMR_TRACKER_DEVICE_IP error ($OMR_TRACKER_LIST_HOSTS)"
|
||||
else
|
||||
OMR_TRACKER_STATUS_MSG="$OMR_TRACKER_STATUS_MSG and $OMR_TRACKER_TYPE from $OMR_TRACKER_DEVICE_IP error ($OMR_TRACKER_LIST_HOSTS)"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
|
Loading…
Reference in a new issue