From 3a9e1af5260b3b2d1379490d249840e5e2ce4125 Mon Sep 17 00:00:00 2001 From: Manuel Munz Date: Sun, 28 Jun 2015 15:55:37 +0200 Subject: [PATCH] Fix routes on freifunk public status page --- .../luasrc/view/freifunk/public_status.htm | 75 ++++++++++--------- 1 file changed, 38 insertions(+), 37 deletions(-) diff --git a/modules/luci-mod-freifunk/luasrc/view/freifunk/public_status.htm b/modules/luci-mod-freifunk/luasrc/view/freifunk/public_status.htm index 42a58f9dd..257f9caf1 100644 --- a/modules/luci-mod-freifunk/luasrc/view/freifunk/public_status.htm +++ b/modules/luci-mod-freifunk/luasrc/view/freifunk/public_status.htm @@ -49,6 +49,32 @@ for _, dev in ipairs(devices) do end local has_iwinfo = pcall(require, "iwinfo") + +-- Find default routes + +local _, r, def4, def6 + +for _, r in ipairs(ip.routes({ type = 1, dest_exact = "0.0.0.0/0" })) do + def4 = { + gateway = r.gw:string(), + dest = r.dest:string(), + dev = r.dev, + metr = r.metric or 0 + } + break +end + +for _, r in ipairs(ip.routes({ type = 1, dest_exact = "::/0" })) do + def6 = { + gateway = r.gw:string(), + dest = r.dest:string(), + dev = r.dev, + metr = r.metric or 0 + } + break +end + + if luci.http.formvalue("status") == "1" then local rv = { } for dev in pairs(netdevs) do @@ -67,30 +93,6 @@ if luci.http.formvalue("status") == "1" then end - -- Find default routes - - local _, r, def4, def6 - - for _, r in ipairs(ip.routes({ type = 1, dest_exact = "0.0.0.0/0" })) do - def4 = { - gateway = r.gw:string(), - dest = r.dest:string(), - dev = r.dev, - metr = r.metric or 0 - } - break - end - - for _, r in ipairs(ip.routes({ type = 1, dest_exact = "::/0" })) do - def6 = { - gateway = r.gw:string(), - dest = r.dest:string(), - dev = r.dev, - metr = r.metric or 0 - } - break - end - rv[#rv+1] = { time = time, uptime = uptime, @@ -297,7 +299,7 @@ end if bitrate ~= "N/A" then bitrate = ( bitrate / 1000 ).."Mb/s" end - local interface = net.iwdata.ifname or "N/A" + local interface = netiwdata.ifname or "N/A" %> <%=signal_string%> @@ -323,7 +325,7 @@ end
-<% if not defroutev4 and not defroutev6 then %> +<% if not def4 and not def6 then %> <%:No default routes known.%> <%else%> @@ -334,23 +336,22 @@ end - <% if defroutev4 then %> - + <% if def4 then %> - - - - + + + + <% end - if defroutev6 then %> + if def6 then %> - - - - + + + + <% end %> -- 2.25.1
<%:Metric%>
<%=defroutev4.dest%><%=defroutev4.device%><%=defroutev4.gateway%><%=defroutev4.metric%><%=def4.dest%><%=def4.dev%><%=def4.gateway%><%=def4.metr%>
<%=defroutev6.dest%><%=defroutev6.device%><%=defroutev6.nexthop%><%=defroutev6.metric%><%=def6.dest%><%=def6.dev%><%=def6.gateway%><%=def6.metr%>