From 8b5816e4f98416948fc9323ae863b1f723f3efd2 Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Thu, 25 Mar 2021 16:36:28 +0100 Subject: [PATCH] Fix link status in status page --- .../luasrc/view/openmptcprouter/wanstatus.htm | 16 ++++++++++++-- .../root/usr/libexec/rpcd/openmptcprouter | 21 +++++-------------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/luci-app-openmptcprouter/luasrc/view/openmptcprouter/wanstatus.htm b/luci-app-openmptcprouter/luasrc/view/openmptcprouter/wanstatus.htm index 074a047db..0502faea3 100644 --- a/luci-app-openmptcprouter/luasrc/view/openmptcprouter/wanstatus.htm +++ b/luci-app-openmptcprouter/luasrc/view/openmptcprouter/wanstatus.htm @@ -428,11 +428,13 @@ local statuslogo = ucic:get("openmptcprouter","settings","statuslogo") or "openm var whois = mArray.wans[i].whois; var whois6 = mArray.wans[i].whois6; var signal = mArray.wans[i].signal; + var status = mArray.wans[i].status; var multipath = mArray.wans[i].multipath; if(multipath == 'master') { master++; } + var zonewan = mArray.wans[i].zonewan; var latency = mArray.wans[i].latency; var mtu = mArray.wans[i].mtu; var operator = mArray.wans[i].operator; @@ -568,12 +570,12 @@ local statuslogo = ucic:get("openmptcprouter","settings","statuslogo") or "openm { statusMessage += '<%:No Server http response after 1 second%>' + '
'; } - if (stat == 'Offline' && ipaddr != '' && ipaddr == mArray.wans[i].gateway) + if (status == 'ERROR' && ipaddr != '' && ipaddr == mArray.wans[i].gateway) { statusMessage += '<%:Wan IP and gateway are identical%>' + '
'; statusMessageClass = "error"; } - if (stat == 'Offline' && ip6addr != '' && ip6addr == mArray.wans[i].gateway6) + if (status == 'ERROR' && ip6addr != '' && ip6addr == mArray.wans[i].gateway6) { statusMessage += '<%:Wan IP and gateway are identical%>' + '
'; statusMessageClass = "error"; @@ -612,6 +614,11 @@ local statuslogo = ucic:get("openmptcprouter","settings","statuslogo") or "openm statusMessage += '<%:Network interface MAC address duplicated%>' + '
'; statusMessageClass = "error"; } + if(zonewan == "NO") + { + statusMessage += '<%:Network interface not in WAN firewall zone%>' + '
'; + statusMessageClass = "error"; + } if(ipv6_discover == 'DETECTED') { statusMessage += '<%:IPv6 route received%>' + '
' @@ -621,6 +628,11 @@ local statuslogo = ucic:get("openmptcprouter","settings","statuslogo") or "openm statusMessageClass = "warning"; statusIcon = "<%=resource%>/openmptcprouter/images/statusWarning.png"; } + if (statusMessage !== "" && statusMessageClass == "error") + { + statusMessageClass = "error"; + statusIcon = "<%=resource%>/openmptcprouter/images/statusError.png"; + } content += String.format('<%:multipath:%> %s
',multipath); if(mArray.wans[i].qos && mArray.wans[i].download > 0 && mArray.wans[i].upload > 0) { diff --git a/luci-app-openmptcprouter/root/usr/libexec/rpcd/openmptcprouter b/luci-app-openmptcprouter/root/usr/libexec/rpcd/openmptcprouter index 9ed558f76..b5c0a452f 100755 --- a/luci-app-openmptcprouter/root/usr/libexec/rpcd/openmptcprouter +++ b/luci-app-openmptcprouter/root/usr/libexec/rpcd/openmptcprouter @@ -1121,7 +1121,7 @@ function interfaces_status() local ipv6 = section["ipv6"] or "0" local mac = section ["macaddr"] or "" local itype = section ["type"] or "" - local state = section ["state"] or "" + local state = uci:get("openmptcprouter", interface, "state") or "" --if not ipaddr or not gateway then return end -- Don't show if0 in the overview @@ -1358,28 +1358,17 @@ function interfaces_status() if mArray.openmptcprouter["service_addr_ip"] ~= "" then server_http_test = sys.exec("httping -l " .. mArray.openmptcprouter["service_addr_ip"] .. ":" .. adminport .. " -y " .. ipaddr .. " -t 1 -c 1") server_http_result = ut.trim(sys.exec("echo '" .. server_http_test .. "' | grep '100.00% failed'")) - if server_http_result ~= "" then - server_http = "DOWN" - if connectivity == "OK" then - connectivity = "WARNING" - end - end - end - if mArray.openmptcprouter["service_addr_ip6"] ~= "" then + elseif mArray.openmptcprouter["service_addr_ip6"] ~= "" then server_http_test = sys.exec("httping -l [" .. mArray.openmptcprouter["service_addr_ip6"] .. "]:" .. adminport .. " -y " .. ipaddr .. " -t 1 -c 1") server_http_result = ut.trim(sys.exec("echo '" .. server_http_test .. "' | grep '100.00% failed'")) - if server_http_result ~= "" then - server_http = "DOWN" - if connectivity == "OK" then - connectivity = "WARNING" - end - end end if server_http_result ~= "" then server_http = "DOWN" if connectivity == "OK" then connectivity = "WARNING" end + else + server_http = "UP" end end end @@ -1401,7 +1390,7 @@ function interfaces_status() end local zonewan = "NO" - if ut.trim(sys.exec("uci -q get firewall.zone_wan.networks | grep '" .. interface .. "'")) ~= "" then + if ut.trim(sys.exec("uci -q get firewall.zone_wan.network | grep '" .. interface .. "'")) ~= "" then zonewan = "OK" end