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

Fix status displayed gateway when a static route is set

This commit is contained in:
Ycarus (Yannick Chabanois) 2022-07-28 19:14:48 +02:00
parent 04c4161845
commit bc139fb048

View file

@ -1244,18 +1244,10 @@ function interfaces_status()
-- Detect WAN gateway status
local gw_ping = "UP"
local gw_ping6 = "UP"
if ifname ~= nil and not (ifname:match("^tun.*") or interface:match("^ovpn.*") or interface:match("^wg.*")) then
if proto ~= "dhcpv6" then
gateway = ut.trim(sys.exec("ip -4 r list dev " .. ifname .. " | grep via | grep -v default | grep -v metric | awk '{print $1}' | tr -d '\n'"))
end
if ipv6 == "1" or ipv6 == "auto" then
gateway6 = ut.trim(sys.exec("ip -6 r list dev " .. ifname .. " | grep via | grep -v default | grep -v metric | awk '{print $1}' | tr -d '\n'"))
end
end
if gateway == "" and proto ~= "dhcpv6" then
gateway = get_gateway(interface)
end
if gateway == "" and ifname ~= nil and ifname ~= "" and ipv6 ~= "1" and ipv6 ~= "auto" then
if fs.access("/sys/class/net/" .. ifname) then
gateway = ut.trim(sys.exec("ip -4 r list dev " .. ifname .. " | grep kernel | awk '/proto kernel/ {print $1}' | grep -v / | tr -d '\n'"))
@ -1264,6 +1256,11 @@ function interfaces_status()
end
end
end
if ifname ~= nil and not (ifname:match("^tun.*") or interface:match("^ovpn.*") or interface:match("^wg.*")) then
if proto ~= "dhcpv6" and gateway == "" then
gateway = ut.trim(sys.exec("ip -4 r list dev " .. ifname .. " | grep via | grep -v default | grep -v metric | awk '{print $1}' | tr -d '\n'"))
end
end
if gateway6 == "" and (ipv6 == "1" or ipv6 == "auto") then
gateway6 = get_gateway6(interface)
end
@ -1275,6 +1272,11 @@ function interfaces_status()
end
end
end
if ifname ~= nil and not (ifname:match("^tun.*") or interface:match("^ovpn.*") or interface:match("^wg.*")) then
if ipv6 == "1" or ipv6 == "auto" and gateway6 == ""then
gateway6 = ut.trim(sys.exec("ip -6 r list dev " .. ifname .. " | grep via | grep -v default | grep -v metric | awk '{print $1}' | tr -d '\n'"))
end
end
local signal = ""
local operator = ""
local phonenumber = ""