Merge pull request #629 from chris5560/master

sys.lua _nethints(): read location of dhcp.lease file from uci
This commit is contained in:
Jo-Philipp Wich 2016-01-23 17:09:27 +01:00
commit 8d451c77c1
2 changed files with 11 additions and 7 deletions

View file

@ -185,14 +185,18 @@ local function _nethints(what, callback)
end
end
if fs.access("/var/dhcp.leases") then
for e in io.lines("/var/dhcp.leases") do
mac, ip, name = e:match("^%d+ (%S+) (%S+) (%S+)")
if mac and ip then
_add(what, mac:upper(), ip, nil, name ~= "*" and name)
cur:foreach("dhcp", "dnsmasq",
function(s)
if s.leasefile and fs.access(s.leasefile) then
for e in io.lines(s.leasefile) do
mac, ip, name = e:match("^%d+ (%S+) (%S+) (%S+)")
if mac and ip then
_add(what, mac:upper(), ip, nil, name ~= "*" and name)
end
end
end
end
end
)
cur:foreach("dhcp", "host",
function(s)

View file

@ -8,7 +8,7 @@ local uci = require "luci.model.uci".cursor()
local function dhcp_leases_common(family)
local rv = { }
local nfs = require "nixio.fs"
local leasefile = "/var/dhcp.leases"
local leasefile = "/tmp/dhcp.leases"
uci:foreach("dhcp", "dnsmasq",
function(s)