1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-feeds.git synced 2025-03-09 15:40:03 +00:00

Fix gateway detection in some case

This commit is contained in:
Ycarus 2019-01-03 11:49:05 +01:00
parent 83ff408cf9
commit 2acf3a2b41

View file

@ -101,12 +101,18 @@ interface_multipath_settings() {
[ -z "$gateway" ] && gateway=$(ip -4 r list dev $iface | grep -v default | awk '/proto static/ {print $1}' | tr -d "\n")
[ -z "$gateway" ] && gateway=$(uci -q get "network.$config.gateway")
[ -z "$gateway" ] && gateway=$(ubus call network.interface.$config status | jsonfilter -q -e '@.route[0].nexthop' | tr -d "\n")
if [ -z "$gateway" ] || [ "$( valid_subnet4 $gateway )" != "ok" ]; then
gateway=$(ubus call network.interface.$config status | jsonfilter -q -e '@.route[1].nexthop' | tr -d "\n")
fi
if [ -z "$gateway" ] || [ "$( valid_subnet4 $gateway )" != "ok" ]; then
gateway=$(ubus call network.interface.$config status | jsonfilter -q -e '@.inactive.route[0].nexthop' | tr -d "\n")
fi
if [ -z "$gateway" ] || [ "$( valid_subnet4 $gateway )" != "ok" ]; then
gateway=$(ubus call network.interface.${config}_4 status 2>/dev/null | jsonfilter -q -e '@.inactive.route[0].nexthop' | tr -d "\n")
fi
if [ -z "$gateway" ] || [ "$( valid_subnet4 $gateway )" != "ok" ]; then
gateway=$(ubus call network.interface.${config}_4 status 2>/dev/null | jsonfilter -q -e '@.route[0].nexthop' | tr -d "\n")
fi
network_get_subnet netmask $config
[ -z "$netmask" ] && netmask=$(ip -4 addr show dev $iface | grep peer | awk '{print $4}' | cut -d/ -f2 | tr -d "\n")
[ -z "$netmask" ] && netmask=$(ip -4 addr show dev $iface | grep inet | awk '{print $2}' | cut -d/ -f2 | tr -d "\n")