diff options
author | Jo-Philipp Wich <jo@mein.io> | 2017-07-10 16:08:21 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2017-07-11 14:05:31 +0200 |
commit | b2154e0b632d28ba949092a19f95d5d8804e9a94 (patch) | |
tree | bbd047e2192f442bbe94f7a630be4897256ce0ac /modules/luci-mod-admin-mini/luasrc/model | |
parent | 198e4ab17b36da30719d2941f13f7336aaee05bc (diff) |
luci-mod-admin-mini: eliminate use of luci.sys.net.deviceinfo()
The luci-mod-admin-mini network controller is the only remaining user of the
deviceinfo() call so inline the required code there so that the function can
be dropped from base LuCI in a later commit.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules/luci-mod-admin-mini/luasrc/model')
-rw-r--r-- | modules/luci-mod-admin-mini/luasrc/model/cbi/mini/network.lua | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/modules/luci-mod-admin-mini/luasrc/model/cbi/mini/network.lua b/modules/luci-mod-admin-mini/luasrc/model/cbi/mini/network.lua index c895430a3b..7bc4df859b 100644 --- a/modules/luci-mod-admin-mini/luasrc/model/cbi/mini/network.lua +++ b/modules/luci-mod-admin-mini/luasrc/model/cbi/mini/network.lua @@ -5,15 +5,40 @@ local wa = require "luci.tools.webadmin" local sys = require "luci.sys" local fs = require "nixio.fs" +local nx = require "nixio" local has_pptp = fs.access("/usr/sbin/pptp") local has_pppoe = fs.glob("/usr/lib/pppd/*/rp-pppoe.so")() local network = luci.model.uci.cursor_state():get_all("network") -local netstat = sys.net.deviceinfo() +local netstat = {} local ifaces = {} +local k, v +for k, v in ipairs(nx.getifaddrs()) do + if v.family == "packet" then + local d = v.data + d[1] = d.rx_bytes + d[2] = d.rx_packets + d[3] = d.rx_errors + d[4] = d.rx_dropped + d[5] = 0 + d[6] = 0 + d[7] = 0 + d[8] = d.multicast + d[9] = d.tx_bytes + d[10] = d.tx_packets + d[11] = d.tx_errors + d[12] = d.tx_dropped + d[13] = 0 + d[14] = d.collisions + d[15] = 0 + d[16] = 0 + netstat[v.name] = d + end +end + for k, v in pairs(network) do if v[".type"] == "interface" and k ~= "loopback" then table.insert(ifaces, v) |