From 1bb4822dca6113f73e3bc89e2acf15935e6f8e92 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Wed, 3 Dec 2014 15:17:05 +0100 Subject: Rework LuCI build system * Rename subdirectories to their repective OpenWrt package names * Make each LuCI module its own standalone package * Deploy a shared luci.mk which is used by each module Makefile Signed-off-by: Jo-Philipp Wich --- .../luasrc/view/admin_status/bandwidth.htm | 311 +++++++++ .../luasrc/view/admin_status/connections.htm | 382 +++++++++++ .../luasrc/view/admin_status/dmesg.htm | 20 + .../luasrc/view/admin_status/index.htm | 713 +++++++++++++++++++++ .../luasrc/view/admin_status/iptables.htm | 159 +++++ .../luasrc/view/admin_status/load.htm | 291 +++++++++ .../luasrc/view/admin_status/routes.htm | 107 ++++ .../luasrc/view/admin_status/syslog.htm | 20 + .../luasrc/view/admin_status/wireless.htm | 378 +++++++++++ 9 files changed, 2381 insertions(+) create mode 100644 modules/luci-mod-admin-full/luasrc/view/admin_status/bandwidth.htm create mode 100644 modules/luci-mod-admin-full/luasrc/view/admin_status/connections.htm create mode 100644 modules/luci-mod-admin-full/luasrc/view/admin_status/dmesg.htm create mode 100644 modules/luci-mod-admin-full/luasrc/view/admin_status/index.htm create mode 100644 modules/luci-mod-admin-full/luasrc/view/admin_status/iptables.htm create mode 100644 modules/luci-mod-admin-full/luasrc/view/admin_status/load.htm create mode 100644 modules/luci-mod-admin-full/luasrc/view/admin_status/routes.htm create mode 100644 modules/luci-mod-admin-full/luasrc/view/admin_status/syslog.htm create mode 100644 modules/luci-mod-admin-full/luasrc/view/admin_status/wireless.htm (limited to 'modules/luci-mod-admin-full/luasrc/view/admin_status') diff --git a/modules/luci-mod-admin-full/luasrc/view/admin_status/bandwidth.htm b/modules/luci-mod-admin-full/luasrc/view/admin_status/bandwidth.htm new file mode 100644 index 0000000000..0c53c95bed --- /dev/null +++ b/modules/luci-mod-admin-full/luasrc/view/admin_status/bandwidth.htm @@ -0,0 +1,311 @@ +<%# +LuCI - Lua Configuration Interface +Copyright 2010 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 ntm = require "luci.model.network".init() + + local dev + local devices = { } + for _, dev in luci.util.vspairs(luci.sys.net.devices()) do + if dev ~= "lo" and not ntm:ignore_interface(dev) then + devices[#devices+1] = dev + end + end + + local curdev = luci.dispatcher.context.requestpath + curdev = curdev[#curdev] ~= "bandwidth" and curdev[#curdev] or devices[1] +-%> + +<%+header%> + + + + +

<%:Realtime Traffic%>

+ + + + +
-
+
+ + + + + + + + + + + + + + + + + + + + + + +
<%:Inbound:%>0 <%:kbit/s%>
(0 <%:kB/s%>)
<%:Average:%>0 <%:kbit/s%>
(0 <%:kB/s%>)
<%:Peak:%>0 <%:kbit/s%>
(0 <%:kB/s%>)
<%:Outbound:%>0 <%:kbit/s%>
(0 <%:kB/s%>)
<%:Average:%>0 <%:kbit/s%>
(0 <%:kB/s%>)
<%:Peak:%>0 <%:kbit/s%>
(0 <%:kB/s%>)
+ +<%+footer%> diff --git a/modules/luci-mod-admin-full/luasrc/view/admin_status/connections.htm b/modules/luci-mod-admin-full/luasrc/view/admin_status/connections.htm new file mode 100644 index 0000000000..80c8b70e3c --- /dev/null +++ b/modules/luci-mod-admin-full/luasrc/view/admin_status/connections.htm @@ -0,0 +1,382 @@ +<%# +LuCI - Lua Configuration Interface +Copyright 2010 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 + +-%> + +<%+header%> + + + + +

<%:Realtime Connections%>

+ +
<%:This page gives an overview over currently active network connections.%>
+ +
+ <%:Active Connections%> + + +
-
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
<%:UDP:%>0<%:Average:%>0<%:Peak:%>0
<%:TCP:%>0<%:Average:%>0<%:Peak:%>0
<%:Other:%>0<%:Average:%>0<%:Peak:%>0
+
+ +
+ + + + + + + + + + +
<%:Network%><%:Protocol%><%:Source%><%:Destination%><%:Transfer%>
<%:Collecting data...%>
+
+
+ +<%+footer%> diff --git a/modules/luci-mod-admin-full/luasrc/view/admin_status/dmesg.htm b/modules/luci-mod-admin-full/luasrc/view/admin_status/dmesg.htm new file mode 100644 index 0000000000..7757460a05 --- /dev/null +++ b/modules/luci-mod-admin-full/luasrc/view/admin_status/dmesg.htm @@ -0,0 +1,20 @@ +<%# +LuCI - Lua Configuration Interface +Copyright 2008 Steven Barth +Copyright 2008 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: syslog.htm 3622 2008-10-23 16:05:55Z jow $ + +-%> +<%+header%> +

<%:Kernel Log%>

+
+ +
+<%+footer%> diff --git a/modules/luci-mod-admin-full/luasrc/view/admin_status/index.htm b/modules/luci-mod-admin-full/luasrc/view/admin_status/index.htm new file mode 100644 index 0000000000..cfeb91ac7a --- /dev/null +++ b/modules/luci-mod-admin-full/luasrc/view/admin_status/index.htm @@ -0,0 +1,713 @@ +<%# +LuCI - Lua Configuration Interface +Copyright 2008 Steven Barth +Copyright 2008-2011 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 + +-%> + +<% + require "luci.fs" + require "luci.tools.status" + + local has_ipv6 = luci.fs.access("/proc/net/ipv6_route") + local has_dhcp = luci.fs.access("/etc/config/dhcp") + local has_wifi = luci.fs.stat("/etc/config/wireless") + has_wifi = has_wifi and has_wifi.size > 0 + local _, _, memtotal, memcached, membuffers, memfree, _, swaptotal, swapcached, swapfree = luci.sys.sysinfo() + local has_swap + if swaptotal > 0 then + has_swap = 1 + end + local has_dsl = luci.fs.stat("/etc/init.d/dsl_control") + + if luci.http.formvalue("status") == "1" then + local ntm = require "luci.model.network".init() + local wan = ntm:get_wannet() + local wan6 = ntm:get_wan6net() + + local conn_count = tonumber(( + luci.sys.exec("wc -l /proc/net/nf_conntrack") or + luci.sys.exec("wc -l /proc/net/ip_conntrack") or + ""):match("%d+")) or 0 + + local conn_max = tonumber(( + luci.sys.exec("sysctl net.nf_conntrack_max") or + luci.sys.exec("sysctl net.ipv4.netfilter.ip_conntrack_max") or + ""):match("%d+")) or 4096 + + local rv = { + uptime = luci.sys.uptime(), + localtime = os.date(), + loadavg = { luci.sys.loadavg() }, + memtotal = memtotal, + memcached = memcached, + membuffers = membuffers, + memfree = memfree, + swaptotal = swaptotal, + swapcached = swapcached, + swapfree = swapfree, + connmax = conn_max, + conncount = conn_count, + leases = luci.tools.status.dhcp_leases(), + leases6 = luci.tools.status.dhcp6_leases(), + wifinets = luci.tools.status.wifi_networks() + } + + if wan then + rv.wan = { + ipaddr = wan:ipaddr(), + gwaddr = wan:gwaddr(), + netmask = wan:netmask(), + dns = wan:dnsaddrs(), + expires = wan:expires(), + uptime = wan:uptime(), + proto = wan:proto(), + ifname = wan:ifname(), + link = wan:adminlink() + } + end + + if wan6 then + rv.wan6 = { + ip6addr = wan6:ip6addr(), + gw6addr = wan6:gw6addr(), + dns = wan6:dns6addrs(), + uptime = wan6:uptime(), + ifname = wan6:ifname(), + link = wan6:adminlink() + } + end + + if has_dsl then + local dsl_stat = luci.sys.exec("/etc/init.d/dsl_control lucistat") + local dsl_func = loadstring(dsl_stat) + rv.dsl = dsl_func() + end + + luci.http.prepare_content("application/json") + luci.http.write_json(rv) + + return + end + + local system, model = luci.sys.sysinfo() +-%> + +<%+header%> + + + + +

<%:Status%>

+ +
+ <%:System%> + + + + + + + + + +
<%:Hostname%><%=luci.sys.hostname() or "?"%>
<%:Model%><%=pcdata(model or "?")%>
<%:Firmware Version%> + <%=pcdata(luci.version.distname)%> <%=pcdata(luci.version.distversion)%> / + <%=pcdata(luci.version.luciname)%> (<%=pcdata(luci.version.luciversion)%>) +
<%:Kernel Version%><%=luci.sys.exec("uname -r")%>
<%:Local Time%>-
<%:Uptime%>-
<%:Load Average%>-
+
+ +
+ <%:Memory%> + + + + + + +
<%:Total Available%>-
<%:Free%>-
<%:Cached%>-
<%:Buffered%>-
+
+ +<% if has_swap then %> +
+ <%:Swap%> + + + + + +
<%:Total Available%>-
<%:Free%>-
<%:Cached%>-
+
+<% end %> + +
+ <%:Network%> + + + + <% if has_ipv6 then %> + + <% end %> + +
<%:IPv4 WAN Status%> + + + +

?
<%:Collecting data...%>
+
<%:IPv6 WAN Status%> + + + +

?
<%:Collecting data...%>
+
<%:Active Connections%>-
+
+ +<% if has_dhcp then %> +
+ <%:DHCP Leases%> + + + + + + + + + + + +
<%:Hostname%><%:IPv4-Address%><%:MAC-Address%><%:Leasetime remaining%>

<%:Collecting data...%>
+
+ + +<% end %> + +<% if has_dsl then %> +
+ <%:ADSL%> + + +
<%:ADSL Status%> + + + +

?
<%:Collecting data...%>
+
+
+<% end %> + +<% if has_wifi then %> +
+ <%:Wireless%> + + + +
<%:Collecting data...%>
+
+ +
+ <%:Associated Stations%> + + + + + + + + + + + + + + +
 <%:MAC-Address%><%:Network%><%:Signal%><%:Noise%><%:RX Rate%><%:TX Rate%>

<%:Collecting data...%>
+
+<% end %> + +<%- + require "luci.util" + require "nixio.fs" + + local plugins = nixio.fs.dir(luci.util.libpath() .. "/view/admin_status/index") + if plugins then + local inc + for inc in plugins do + if inc:match("%.htm$") then + include("admin_status/index/" .. inc:gsub("%.htm$", "")) + end + end + end +-%> + +<%+footer%> diff --git a/modules/luci-mod-admin-full/luasrc/view/admin_status/iptables.htm b/modules/luci-mod-admin-full/luasrc/view/admin_status/iptables.htm new file mode 100644 index 0000000000..957604e8af --- /dev/null +++ b/modules/luci-mod-admin-full/luasrc/view/admin_status/iptables.htm @@ -0,0 +1,159 @@ +<%# +LuCI - Lua Configuration Interface +Copyright 2008-2009 Steven Barth +Copyright 2008-2011 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$ + +-%> + +<%- + + require "luci.sys.iptparser" + require "luci.tools.webadmin" + require "luci.fs" + + local has_ip6tables = luci.fs.access("/usr/sbin/ip6tables") + local mode = 4 + + if has_ip6tables then + mode = luci.dispatcher.context.requestpath + mode = tonumber(mode[#mode] ~= "iptables" and mode[#mode]) or 4 + end + + local ipt = luci.sys.iptparser.IptParser(mode) + local wba = luci.tools.webadmin + + local rowcnt = 1 + function rowstyle() + rowcnt = rowcnt + 1 + return (rowcnt % 2) + 1 + end + + function link_target(t,c) + if ipt:is_custom_target(c) then + return '%s' %{ t:lower(), c, c } + end + return c + end + + function link_iface(i) + local net = wba.iface_get_network(i) + if net and i ~= "lo" then + return '%s' %{ + luci.dispatcher.build_url("admin", "network", "network", net), i + } + + end + return i + end + + local tables = { "Filter", "NAT", "Mangle", "Raw" } + if mode == 6 then + tables = { "Filter", "Mangle", "Raw" } + end +-%> + +<%+header%> + + + +

<%:Firewall Status%>

+ +<% if has_ip6tables then %> + +<% end %> + +
+
+
+

<%:Actions%>

+ +

+ + <% for _, tbl in ipairs(tables) do chaincnt = 0 %> +

<%:Table%>: <%=tbl%>

+ + <% for _, chain in ipairs(ipt:chains(tbl)) do + rowcnt = 0 + chaincnt = chaincnt + 1 + chaininfo = ipt:chain(tbl, chain) + %> + + + + + + + + + + + + + + + + + + <% for _, rule in ipairs(ipt:find({table=tbl, chain=chain})) do %> + + + + + + + + + + + + + + <% end %> + + <% if rowcnt == 1 then %> + + + + <% end %> + <% end %> + + <% if chaincnt == 0 then %> + + + + <% end %> +
+
+ <%:Chain%> <%=chain%> + (<%- if chaininfo.policy then -%> + <%:Policy%>: <%=chaininfo.policy%>, <%:Packets%>: <%=chaininfo.packets%>, <%:Traffic%>: <%=wba.byte_format(chaininfo.bytes)-%> + <%- else -%> + <%:References%>: <%=chaininfo.references-%> + <%- end -%>) +
<%:Rule #%><%:Pkts.%><%:Traffic%><%:Target%><%:Prot.%><%:Flags%><%:In%><%:Out%><%:Source%><%:Destination%><%:Options%>
<%=rule.index%><%=rule.packets%><%=wba.byte_format(rule.bytes)%><%=rule.target and link_target(tbl, rule.target) or "-"%><%=rule.protocol%><%=rule.flags%><%=link_iface(rule.inputif)%><%=link_iface(rule.outputif)%><%=rule.source%><%=rule.destination%><%=#rule.options > 0 and luci.util.pcdata(table.concat(rule.options, " ")) or "-"%>
<%:No rules in this chain%>
<%:No chains in this table%>
+

+ <% end %> +
+
+
+ +<%+footer%> diff --git a/modules/luci-mod-admin-full/luasrc/view/admin_status/load.htm b/modules/luci-mod-admin-full/luasrc/view/admin_status/load.htm new file mode 100644 index 0000000000..a002715ec8 --- /dev/null +++ b/modules/luci-mod-admin-full/luasrc/view/admin_status/load.htm @@ -0,0 +1,291 @@ +<%# +LuCI - Lua Configuration Interface +Copyright 2010 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 + +-%> + +<%+header%> + + + + +

<%:Realtime Load%>

+ + +
-
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
<%:1 Minute Load:%>0<%:Average:%>0<%:Peak:%>0
<%:5 Minute Load:%>0<%:Average:%>0<%:Peak:%>0
<%:15 Minute Load:%>0<%:Average:%>0<%:Peak:%>0
+ +<%+footer%> diff --git a/modules/luci-mod-admin-full/luasrc/view/admin_status/routes.htm b/modules/luci-mod-admin-full/luasrc/view/admin_status/routes.htm new file mode 100644 index 0000000000..4e7287b705 --- /dev/null +++ b/modules/luci-mod-admin-full/luasrc/view/admin_status/routes.htm @@ -0,0 +1,107 @@ +<%# +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$ + +-%> + +<%- + require "bit" + require "luci.sys" + require "luci.tools.webadmin" + require "nixio.fs" + + local style = true +-%> + +<%+header%> + +
+

<%:Routes%>

+
<%:The following rules are currently active on this system.%>
+ +
+ ARP +
+ + + + + + + + <% luci.sys.net.arptable(function(e) %> + + + + + + <% style = not style; end) %> +
<%_IPv4-Address%><%_MAC-Address%><%:Interface%>
<%=e["IP address"]%><%=e["HW address"]%><%=e["Device"]%>
+
+
+
+ +
+ <%_Active IPv4-Routes%> + +
+ + + + + + + + <% luci.sys.net.routes(function(rt) %> + + + + + + + <% style = not style; end) %> +
<%:Network%><%:Target%><%_IPv4-Gateway%><%:Metric%>
<%=luci.tools.webadmin.iface_get_network(rt.device) or rt.device%><%=rt.dest:string()%><%=rt.gateway:string()%><%=rt.metric%>
+
+
+
+ + <% if nixio.fs.access("/proc/net/ipv6_route") then + style = true + fe80 = luci.ip.IPv6("fe80::/10") + %> +
+ <%_Active IPv6-Routes%> + +
+ + + + + + + + <% luci.sys.net.routes6(function(rt) if fe80:contains(rt.dest) then return end %> + + + + + + + <% style = not style; end) %> +
<%:Network%><%:Target%><%_IPv6-Gateway%><%:Metric%>
<%=luci.tools.webadmin.iface_get_network(rt.device) or '(' .. rt.device .. ')'%><%=rt.dest:string()%><%=rt.source:string()%><%=rt.metric_raw:upper()%>
+
+
+
+ <% end %> +
+ +<%+footer%> diff --git a/modules/luci-mod-admin-full/luasrc/view/admin_status/syslog.htm b/modules/luci-mod-admin-full/luasrc/view/admin_status/syslog.htm new file mode 100644 index 0000000000..06aeeb01a6 --- /dev/null +++ b/modules/luci-mod-admin-full/luasrc/view/admin_status/syslog.htm @@ -0,0 +1,20 @@ +<%# +LuCI - Lua Configuration Interface +Copyright 2008 Steven Barth +Copyright 2008 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$ + +-%> +<%+header%> +

<%:System Log%>

+
+ +
+<%+footer%> diff --git a/modules/luci-mod-admin-full/luasrc/view/admin_status/wireless.htm b/modules/luci-mod-admin-full/luasrc/view/admin_status/wireless.htm new file mode 100644 index 0000000000..465143ebce --- /dev/null +++ b/modules/luci-mod-admin-full/luasrc/view/admin_status/wireless.htm @@ -0,0 +1,378 @@ +<%# +LuCI - Lua Configuration Interface +Copyright 2011 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 + +-%> + +<%- + local ntm = require "luci.model.network".init() + + local dev + local devices = { } + for _, dev in luci.util.vspairs(luci.sys.net.devices()) do + if dev:match("^wlan%d") or dev:match("^ath%d") or dev:match("^wl%d") then + devices[#devices+1] = dev + end + end + + local curdev = luci.dispatcher.context.requestpath + curdev = curdev[#curdev] ~= "wireless" and curdev[#curdev] or devices[1] +-%> + +<%+header%> + + + + +

<%:Realtime Wireless%>

+ + + + +
-
+
+ + + + + + + + + + + + + + + + + + + + + + +
<%:Signal:%>0 <%:dBm%><%:Average:%>0 <%:dBm%><%:Peak:%>0 <%:dBm%>
<%:Noise:%>0 <%:dBm%><%:Average:%>0 <%:dBm%><%:Peak:%>0 <%:dBm%>
+ +
+ + +
-
+
+ + + + + + + + + + + + +
<%:Phy Rate:%>0 MBit/s<%:Average:%>0 MBit/s<%:Peak:%>0 MBit/s
+ +<%+footer%> -- cgit v1.2.3