mirror of https://github.com/lcpz/lain.git
Update net.lua
This commit is contained in:
parent
af125b324e
commit
0775f97b42
|
@ -29,13 +29,14 @@ local function factory(args)
|
||||||
net.iface = (args.iface and (type(args.iface) == "string" and {args.iface}) or
|
net.iface = (args.iface and (type(args.iface) == "string" and {args.iface}) or
|
||||||
(type(args.iface) == "table" and args.iface)) or {}
|
(type(args.iface) == "table" and args.iface)) or {}
|
||||||
|
|
||||||
function net.get_device()
|
function net.get_devices()
|
||||||
|
net.iface = {} -- reset at every call
|
||||||
helpers.line_callback("ip link", function(line)
|
helpers.line_callback("ip link", function(line)
|
||||||
net.iface[#net.iface + 1] = not string.match(line, "LOOPBACK") and string.match(line, "(%w+): <") or nil
|
net.iface[#net.iface + 1] = not string.match(line, "LOOPBACK") and string.match(line, "(%w+): <") or nil
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
if #net.iface == 0 then net.get_device() end
|
if #net.iface == 0 then net.get_devices() end
|
||||||
|
|
||||||
function net.update()
|
function net.update()
|
||||||
-- These are the totals over all specified interfaces
|
-- These are the totals over all specified interfaces
|
||||||
|
|
Loading…
Reference in New Issue