modules/admin-full: check /etc/ethers and /var/dhcp.leases for existence before trying to read them
This commit is contained in:
parent
acde973d82
commit
b3e5467ec6
1 changed files with 10 additions and 6 deletions
|
@ -113,14 +113,18 @@ local function arplist(opt)
|
||||||
arp[e["HW address"]:upper()] = { e["IP address"] }
|
arp[e["HW address"]:upper()] = { e["IP address"] }
|
||||||
end
|
end
|
||||||
|
|
||||||
for e in io.lines("/etc/ethers") do
|
if fs.access("/etc/ethers") then
|
||||||
mac, ip = e:match("^([a-f0-9]%S+) (%S+)")
|
for e in io.lines("/etc/ethers") do
|
||||||
if mac and ip then arp[mac:upper()] = { ip } end
|
mac, ip = e:match("^([a-f0-9]%S+) (%S+)")
|
||||||
|
if mac and ip then arp[mac:upper()] = { ip } end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for e in io.lines("/var/dhcp.leases") do
|
if fs.access("/var/dhcp.leases") then
|
||||||
mac, ip, name = e:match("^%d+ (%S+) (%S+) (%S+)")
|
for e in io.lines("/var/dhcp.leases") do
|
||||||
if mac and ip then arp[mac:upper()] = { ip, name ~= "*" and name } end
|
mac, ip, name = e:match("^%d+ (%S+) (%S+) (%S+)")
|
||||||
|
if mac and ip then arp[mac:upper()] = { ip, name ~= "*" and name } end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for mac, e in luci.util.kspairs(arp) do
|
for mac, e in luci.util.kspairs(arp) do
|
||||||
|
|
Loading…
Reference in a new issue