1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-feeds.git synced 2025-02-13 11:01:50 +00:00

Fix and more info for omr-tracker

This commit is contained in:
Ycarus 2018-08-14 10:14:10 +02:00
parent 9e84fb41d5
commit 309bc80c98
2 changed files with 17 additions and 9 deletions

View file

@ -115,7 +115,7 @@ default_gw=$(ip route show default | grep -v metric | awk '/default/ {print $3}'
if [ "$OMR_TRACKER_STATUS" = "ERROR" ]; then if [ "$OMR_TRACKER_STATUS" = "ERROR" ]; then
if [ -d "/sys/class/net/$OMR_TRACKER_DEVICE" ]; then if [ -d "/sys/class/net/$OMR_TRACKER_DEVICE" ]; then
[ "$multipath_status" = "off" ] || { [ "$multipath_status" = "off" ] || {
_log "$OMR_TRACKER_DEVICE switched off" _log "$OMR_TRACKER_DEVICE switched off because $OMR_TRACKER_STATUS_MSG"
if [ "$(sysctl -n net.mptcp.mptcp_enabled | tr -d '\n')" = "1" ]; then if [ "$(sysctl -n net.mptcp.mptcp_enabled | tr -d '\n')" = "1" ]; then
multipath "$OMR_TRACKER_DEVICE" off multipath "$OMR_TRACKER_DEVICE" off
fi fi
@ -136,7 +136,7 @@ if [ "$OMR_TRACKER_STATUS" = "ERROR" ]; then
config_foreach set_route interface $OMR_TRACKER_INTERFACE config_foreach set_route interface $OMR_TRACKER_INTERFACE
fi fi
if [ "$OMR_TRACKER_INTERFACE" = "glorytun" ] || [ "$OMR_TRACKER_INTERFACE" = "omrvpn" ]; then if [ "$OMR_TRACKER_INTERFACE" = "glorytun" ] || [ "$OMR_TRACKER_INTERFACE" = "omrvpn" ]; then
_log "$OMR_TRACKER_INTERFACE down" _log "$OMR_TRACKER_INTERFACE down because $OMR_TRACKER_STATUS_MSG"
#config_load shadowsocks-libev #config_load shadowsocks-libev
#config_foreach del_ss_route server all #config_foreach del_ss_route server all
if [ "$(uci -q show shadowsocks-libev.ss_rules.redir_udp)" = "" ] && [ "$(uci -q show shadowsocks-libev.hi2.mode)" = "tcp_and_udp" ]; then if [ "$(uci -q show shadowsocks-libev.ss_rules.redir_udp)" = "" ] && [ "$(uci -q show shadowsocks-libev.hi2.mode)" = "tcp_and_udp" ]; then

View file

@ -138,6 +138,7 @@ while true; do
# setup tracker variables # setup tracker variables
OMR_TRACKER_DEVICE_IP= OMR_TRACKER_DEVICE_IP=
OMR_TRACKER_STATUS="ERROR" OMR_TRACKER_STATUS="ERROR"
OMR_TRACKER_STATUS_MSG=""
OMR_TRACKER_LATENCY= OMR_TRACKER_LATENCY=
OMR_TRACKER_TIMEOUT=$((rto / 1000 + (rto % 1000 ? 1 : 0))) OMR_TRACKER_TIMEOUT=$((rto / 1000 + (rto % 1000 ? 1 : 0)))
@ -169,16 +170,16 @@ while true; do
if [ "$OMR_TRACKER_TYPE" = "none" ]; then if [ "$OMR_TRACKER_TYPE" = "none" ]; then
OMR_TRACKER_STATUS="OK" OMR_TRACKER_STATUS="OK"
else else
# 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
sleep 1
_restart
done
# setup loop variable # setup loop variable
tries="$OMR_TRACKER_TRIES" tries="$OMR_TRACKER_TRIES"
# loop until tries attempts have been reached # loop until tries attempts have been reached
while [ "$tries" -gt 0 ]; do while [ "$tries" -gt 0 ]; do
# 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
sleep 1
_restart
done
if [ "$OMR_TRACKER_TYPE" = "ping" ]; then if [ "$OMR_TRACKER_TYPE" = "ping" ]; then
_ping "$OMR_TRACKER_HOST" "$OMR_TRACKER_DEVICE_IP" "yes" _ping "$OMR_TRACKER_HOST" "$OMR_TRACKER_DEVICE_IP" "yes"
status=$? status=$?
@ -189,15 +190,22 @@ while true; do
_dns "$OMR_TRACKER_HOST" "$OMR_TRACKER_DEVICE_IP" "yes" _dns "$OMR_TRACKER_HOST" "$OMR_TRACKER_DEVICE_IP" "yes"
status=$? status=$?
fi 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 $status); then
OMR_TRACKER_STATUS_MSG=""
OMR_TRACKER_STATUS="OK" OMR_TRACKER_STATUS="OK"
break break
else
OMR_TRACKER_STATUS_MSG="$OMR_TRACKER_TYPE to $OMR_TRACKER_HOST from $OMR_TRACKER_DEVICE_IP error"
fi fi
tries=$((tries - 1)) tries=$((tries - 1))
OMR_TRACKER_TIMEOUT=$((OMR_TRACKER_TIMEOUT * 2)) OMR_TRACKER_TIMEOUT=$((OMR_TRACKER_TIMEOUT * 2))
sleep 1
_restart
done done
ip route del "$OMR_TRACKER_HOST" via "$OMR_TRACKER_DEVICE_GATEWAY" dev "$OMR_TRACKER_DEVICE" src "$OMR_TRACKER_DEVICE_IP" > /dev/null 2&>1
fi fi
else
OMR_TRACKER_STATUS_MSG="gateway down"
fi fi
fi fi
fi fi