5f48317dc04bb5e3964cac2de1bf598959b61e75
[project/luci.git] / modules / niu / luasrc / view / niu / network.htm
1 <%
2 local uci = require "luci.model.uci"
3 local fs = require "nixio.fs"
4
5 local nws = {}
6 uci.inst_state:foreach("network", "interface", function(s)
7         nws[#nws+1] = s
8 end)
9
10 if uci.inst_state:get("network", "lan", "_ipchanged") and
11 uci.inst_state:revert("network", "lan", "_ipchanged") then
12         include("niu/network/warn_ip_change")
13 end
14
15 local wanon = uci.inst_state:get("network", "wan", "proto")
16 local wanup = uci.inst_state:get("network", "wan", "up")
17 local wanip = uci.inst_state:get("network", "wan", "ipaddr")
18
19 local leasefn
20 uci.inst:foreach("dhcp", "dnsmasq",
21  function(section)
22         leasefn = section.leasefile
23  end
24 )
25
26 if leasefn then
27         local ln = fs.access(leasefn, "r") and io.lines(leasefn)
28         leasefn = 0
29         while ln and ln() do
30                 leasefn = leasefn + 1
31         end
32 end
33
34 local arps
35 if fs.access("/proc/net/arp", "r") then
36         local ln = io.lines("/proc/net/arp")
37         arps = -1
38         while ln and ln() do
39                 arps = arps + 1
40         end
41         arps = arps >= 0 and arps
42 end
43 %>
44
45 <table class="dbstattbl">
46 <% if wanon and wanon ~= "none" then %>
47 <tr>
48 <% if wanup then %>
49 <th>Uplink Address:</th>
50 <td><%=wanip%></td>
51 <% else %>
52 <th>Uplink:</th>
53 <td><span style="color: darkred"><em>offline</em></span>
54 </td>
55 <% end %>
56
57 </tr>
58 <% end %>
59
60 <tr>
61 <th>Local Address:</th><td>
62 <%=uci.inst_state:get("network", "lan", "ipaddr")%>
63 </td>
64 </tr>
65
66 <% if arps then %>
67 <tr>
68 <th>Active IP-Devices:</th><td><%=arps%><% if leasefn then %>
69 (<%=leasefn%> assigned)
70 <% end %></td>
71 </tr>
72 <% end %>
73
74 </table>
75 <br />