refactor get_interface_names: use table.insert
This commit is contained in:
parent
fe76518e48
commit
b44df15f0f
1 changed files with 4 additions and 6 deletions
|
@ -11,13 +11,12 @@ function get_hostname()
|
||||||
end
|
end
|
||||||
|
|
||||||
function get_interfaces_names()
|
function get_interfaces_names()
|
||||||
local i, ret
|
local ret = {}
|
||||||
i = 0
|
|
||||||
ret = {}
|
|
||||||
for name in io.popen("ls -1 /sys/class/net/"):lines() do
|
for name in io.popen("ls -1 /sys/class/net/"):lines() do
|
||||||
|
-- skip loopback ("lo") mac (00:00:00:00:00:00)
|
||||||
if name ~= "lo" then
|
if name ~= "lo" then
|
||||||
i = i + 1
|
table.insert(ret, name)
|
||||||
ret[i] = name
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -41,7 +40,6 @@ local function generate_bat_hosts()
|
||||||
|
|
||||||
local hostname = get_hostname()
|
local hostname = get_hostname()
|
||||||
|
|
||||||
-- skip loopback ("lo") mac (00:00:00:00:00:00)
|
|
||||||
for n, i in ipairs(get_interfaces_names()) do
|
for n, i in ipairs(get_interfaces_names()) do
|
||||||
local address = get_interface_address(i)
|
local address = get_interface_address(i)
|
||||||
ifaces[address] = i
|
ifaces[address] = i
|
||||||
|
|
Loading…
Reference in a new issue