Update net.lua

This commit is contained in:
Luca CPZ 2020-04-29 12:28:39 -05:00 committed by GitHub
parent af125b324e
commit 0775f97b42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -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