From 2176dae3a0a648805f7de447e4af7ead8b7655dd Mon Sep 17 00:00:00 2001 From: Steven Barth Date: Mon, 16 Nov 2009 16:58:48 +0000 Subject: NIU: +PortFw +QoS Reorganize Network --- modules/niu/luasrc/view/niu/network.htm | 27 ++------ modules/niu/luasrc/view/niu/network/conntrack.htm | 75 ----------------------- modules/niu/luasrc/view/niu/traffic.htm | 58 ++++++++++++++++++ modules/niu/luasrc/view/niu/traffic/conntrack.htm | 75 +++++++++++++++++++++++ 4 files changed, 137 insertions(+), 98 deletions(-) delete mode 100644 modules/niu/luasrc/view/niu/network/conntrack.htm create mode 100644 modules/niu/luasrc/view/niu/traffic.htm create mode 100644 modules/niu/luasrc/view/niu/traffic/conntrack.htm (limited to 'modules/niu/luasrc/view') diff --git a/modules/niu/luasrc/view/niu/network.htm b/modules/niu/luasrc/view/niu/network.htm index e49c93065..5f48317dc 100644 --- a/modules/niu/luasrc/view/niu/network.htm +++ b/modules/niu/luasrc/view/niu/network.htm @@ -15,17 +15,6 @@ end local wanon = uci.inst_state:get("network", "wan", "proto") local wanup = uci.inst_state:get("network", "wan", "up") local wanip = uci.inst_state:get("network", "wan", "ipaddr") -local wanif = uci.inst_state:get("network", "wan", "ifname") -local wanul, wandl - -if wanif then - local devstats = fs.readfile("/proc/net/dev") - local rx, tx = devstats:match("%s*"..wanif.. - ":%s*([0-9]+)%s+[0-9]+%s+[0-9]+%s+[0-9]+%s+".. - "[0-9]+%s+[0-9]+%s+[0-9]+%s+[0-9]+%s+([0-9]+)") - wanul = tx and (tonumber(tx) / 1000000000) - wandl = rx and (tonumber(rx) / 1000000000) -end local leasefn uci.inst:foreach("dhcp", "dnsmasq", @@ -57,10 +46,10 @@ end <% if wanon and wanon ~= "none" then %> <% if wanup then %> -Uplink Address +Uplink Address: <%=wanip%> <% else %> -Uplink +Uplink: offline <% end %> @@ -68,23 +57,15 @@ end <% end %> -<% if wanul and wandl then %> - -Uplink Traffic -<%=("%.2f"):format(wandl)%> GB⇓ <%=("%.2f"):format(wanul)%> GB⇑ - - -<% end %> - -Local Address +Local Address: <%=uci.inst_state:get("network", "lan", "ipaddr")%> <% if arps then %> -Active IP-Devices<%=arps%><% if leasefn then %> +Active IP-Devices:<%=arps%><% if leasefn then %> (<%=leasefn%> assigned) <% end %> diff --git a/modules/niu/luasrc/view/niu/network/conntrack.htm b/modules/niu/luasrc/view/niu/network/conntrack.htm deleted file mode 100644 index 09b1d6b1c..000000000 --- a/modules/niu/luasrc/view/niu/network/conntrack.htm +++ /dev/null @@ -1,75 +0,0 @@ -<%# -LuCI - Lua Configuration Interface -Copyright 2008-2009 Steven Barth -Copyright 2008-2009 Jo-Philipp Wich - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -$Id$ - --%> - -<%- - local sys = require "luci.sys" - local style = true --%> - -<%+header%> - -
-

<%:Active Connections%>

-
<%:This page gives an overview over currently active network connections.%>
- -
- ARP -
- - - - - - - - <% sys.net.arptable(function(e) %> - - - - - - <% style = not style; end) %> -
<%_IPv4-Address%><%_MAC-Address%><%:Interface%>
<%=e["IP address"]%><%=e["HW address"]%><%=e["Device"]%>
-
-
-
- -
- <%:Active Connections%> -
- - - - - - - - - <% style = true; sys.net.conntrack(function(c) %> - - - - - - - <% style = not style; end) %> -
<%:Network%><%:Protocol%><%:Source%><%:Destination%>
<%=c.layer3:upper()%><%=c.layer4:upper()%><%=c.src%><%=c.dst%>
-
-
-
-
- -<%+footer%> - diff --git a/modules/niu/luasrc/view/niu/traffic.htm b/modules/niu/luasrc/view/niu/traffic.htm new file mode 100644 index 000000000..97a18a151 --- /dev/null +++ b/modules/niu/luasrc/view/niu/traffic.htm @@ -0,0 +1,58 @@ +<% +local uci = require "luci.model.uci" +local fs = require "nixio.fs" + +local wanon = uci.inst_state:get("network", "wan", "up") == "1" +local wanif = wanon and uci.inst_state:get("network", "wan", "ifname") +local lanif = uci.inst_state:get("network", "lan", "ifname") +local wanul, wandl, lanul, landl +local devstats = fs.readfile("/proc/net/dev") + +local fwav = fs.access("/etc/config/firewall", "r") +local fwon = uci.inst_state:get("firewall", "core", "loaded") == "1" + +if lanif then + local rx, tx = devstats:match("%s*"..lanif.. + ":%s*([0-9]+)%s+[0-9]+%s+[0-9]+%s+[0-9]+%s+".. + "[0-9]+%s+[0-9]+%s+[0-9]+%s+[0-9]+%s+([0-9]+)") + lanul = tx and (tonumber(tx) / 1000000000) + landl = rx and (tonumber(rx) / 1000000000) +end + +if wanif then + local rx, tx = devstats:match("%s*"..wanif.. + ":%s*([0-9]+)%s+[0-9]+%s+[0-9]+%s+[0-9]+%s+".. + "[0-9]+%s+[0-9]+%s+[0-9]+%s+[0-9]+%s+([0-9]+)") + wanul = tx and (tonumber(tx) / 1000000000) + wandl = rx and (tonumber(rx) / 1000000000) +end + +%> + + +<% if wanul and wandl then %> + + + +<% end %> + +<% if lanul and landl then %> + + + +<% end %> + +<% if fwav then %> + + + +<% end %> + +
Uplink Traffic: +<%=("%.2f"):format(wandl)%> GB⇓ <%=("%.2f"):format(wanul)%> GB⇑ +
Local Traffic: +<%=("%.2f"):format(landl)%> GB⇓ <%=("%.2f"):format(lanul)%> GB⇑ +
Firewall: +<%=fwon and translate("active") or translate("inactive")%> +
+
\ No newline at end of file diff --git a/modules/niu/luasrc/view/niu/traffic/conntrack.htm b/modules/niu/luasrc/view/niu/traffic/conntrack.htm new file mode 100644 index 000000000..09b1d6b1c --- /dev/null +++ b/modules/niu/luasrc/view/niu/traffic/conntrack.htm @@ -0,0 +1,75 @@ +<%# +LuCI - Lua Configuration Interface +Copyright 2008-2009 Steven Barth +Copyright 2008-2009 Jo-Philipp Wich + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +$Id$ + +-%> + +<%- + local sys = require "luci.sys" + local style = true +-%> + +<%+header%> + +
+

<%:Active Connections%>

+
<%:This page gives an overview over currently active network connections.%>
+ +
+ ARP +
+ + + + + + + + <% sys.net.arptable(function(e) %> + + + + + + <% style = not style; end) %> +
<%_IPv4-Address%><%_MAC-Address%><%:Interface%>
<%=e["IP address"]%><%=e["HW address"]%><%=e["Device"]%>
+
+
+
+ +
+ <%:Active Connections%> +
+ + + + + + + + + <% style = true; sys.net.conntrack(function(c) %> + + + + + + + <% style = not style; end) %> +
<%:Network%><%:Protocol%><%:Source%><%:Destination%>
<%=c.layer3:upper()%><%=c.layer4:upper()%><%=c.src%><%=c.dst%>
+
+
+
+
+ +<%+footer%> + -- cgit v1.2.3