mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-03-09 15:40:03 +00:00
Fix route creation
This commit is contained in:
parent
1b522d61e3
commit
0c05f504fd
2 changed files with 36 additions and 46 deletions
|
@ -42,14 +42,14 @@ set_ss_route() {
|
|||
nginxip=$(echo $up | cut -d: -f1)
|
||||
if [ "$nginxip" != "" ] && [ "$OMR_TRACKER_DEVICE_GATEWAY" != "" ] && [ "$(ip route show dev $OMR_TRACKER_DEVICE metric $metric | grep $nginxip | grep $OMR_TRACKER_DEVICE_GATEWAY)" = "" ]; then
|
||||
_log "Set server $nginxip route via $OMR_TRACKER_DEVICE"
|
||||
ip route replace $nginxip via $OMR_TRACKER_DEVICE_GATEWAY dev $OMR_TRACKER_DEVICE metric $metric
|
||||
ip route replace $nginxip via $OMR_TRACKER_DEVICE_GATEWAY dev $OMR_TRACKER_DEVICE metric $metric > /dev/null 2>&1
|
||||
fi
|
||||
done
|
||||
else
|
||||
if [ "$metric" != "off" ] && [ "$server_ip" != "" ] && [ "$OMR_TRACKER_DEVICE_GATEWAY" != "" ] && [ "$(ip route show dev $OMR_TRACKER_DEVICE metric $metric | grep $server_ip | grep $OMR_TRACKER_DEVICE_GATEWAY)" = "" ]; then
|
||||
_log "Set server $server_ip route via $OMR_TRACKER_DEVICE metric $metric"
|
||||
ip route del $server_ip metric $metric
|
||||
ip route replace $server_ip via $OMR_TRACKER_DEVICE_GATEWAY dev $OMR_TRACKER_DEVICE metric $metric
|
||||
ip route del $server_ip metric $metric > /dev/null 2>&1
|
||||
ip route replace $server_ip via $OMR_TRACKER_DEVICE_GATEWAY dev $OMR_TRACKER_DEVICE metric $metric > /dev/null 2>&1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
@ -248,24 +248,16 @@ if [ "$multipath_config" = "master" ]; then
|
|||
fi
|
||||
ip route replace default via $OMR_TRACKER_DEVICE_GATEWAY dev $OMR_TRACKER_DEVICE table 991337
|
||||
fi
|
||||
if [ -n "$OMR_TRACKER_DEVICE_IP" ] && [ -n "$OMR_TRACKER_DEVICE_GATEWAY" ]; then
|
||||
#local metric=$(ip rule show | grep -m 1 "$OMR_TRACKER_DEVICE_IP" | awk '{print $5}')
|
||||
local metric=$(ip rule show | grep "$OMR_TRACKER_DEVICE_IP" | grep -m 1 "$OMR_TRACKER_DEVICE" | grep -om1 'lookup [[:digit:]]' | awk '{print $2}')
|
||||
[ -n "$metric" ] && {
|
||||
ip route replace default via $OMR_TRACKER_DEVICE_GATEWAY dev $OMR_TRACKER_DEVICE metric $metric
|
||||
}
|
||||
fi
|
||||
multipath_config="on"
|
||||
else
|
||||
if [ -n "$OMR_TRACKER_DEVICE_IP" ] && [ -n "$OMR_TRACKER_DEVICE_GATEWAY" ]; then
|
||||
#local metric=$(ip rule show | grep -m 1 "$OMR_TRACKER_DEVICE_IP" | awk '{print $5}')
|
||||
local metric=$(ip rule show | grep "$OMR_TRACKER_DEVICE_IP" | grep -m 1 "$OMR_TRACKER_DEVICE" | grep -om1 'lookup [[:digit:]]' | awk '{print $2}')
|
||||
[ -n "$metric" ] && {
|
||||
ip route replace default via $OMR_TRACKER_DEVICE_GATEWAY dev $OMR_TRACKER_DEVICE metric $metric
|
||||
config_load shadowsocks-libev
|
||||
config_foreach set_ss_route server $metric
|
||||
}
|
||||
fi
|
||||
fi
|
||||
if [ -n "$OMR_TRACKER_DEVICE_IP" ] && [ -n "$OMR_TRACKER_DEVICE_GATEWAY" ]; then
|
||||
#local metric=$(ip rule show | grep -m 1 "$OMR_TRACKER_DEVICE_IP" | awk '{print $5}')
|
||||
local metric=$(ip rule show | grep "$OMR_TRACKER_DEVICE_IP" | grep -m 1 "$OMR_TRACKER_DEVICE" | grep -om1 'lookup [[:digit:]]' | awk '{print $2}')
|
||||
[ -n "$metric" ] && {
|
||||
ip route replace default via $OMR_TRACKER_DEVICE_GATEWAY dev $OMR_TRACKER_DEVICE metric $metric
|
||||
config_load shadowsocks-libev
|
||||
config_foreach set_ss_route server $metric
|
||||
}
|
||||
fi
|
||||
|
||||
[ "$multipath_config" = "on" ] && glorytun-udp path $OMR_TRACKER_DEVICE_IP dev tun0 up > /dev/null 2>&1
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue