diff options
author | Ansuel Smith <ansuelsmth@gmail.com> | 2019-06-02 22:37:31 +0200 |
---|---|---|
committer | Ansuel Smith <ansuelsmth@gmail.com> | 2019-06-03 12:51:33 +0200 |
commit | bb34a31e811266ec119002263fa35195bed055db (patch) | |
tree | bdfc979803bd31fef691bc41d00b5fed56337edb /modules | |
parent | 525d62ff333f23552ecdd2d177d64e41544869f9 (diff) |
luci-base: handle dhcp lease from odhcpd
Currently only the dnsmasq lease file is read for hostname hint. If someone use only odhcpd as dhcp daemon the hostname resolution on wifi_assoc list is broken.
Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
Diffstat (limited to 'modules')
-rw-r--r-- | modules/luci-base/luasrc/sys.lua | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/modules/luci-base/luasrc/sys.lua b/modules/luci-base/luasrc/sys.lua index 4c6574368..bb4c67fe8 100644 --- a/modules/luci-base/luasrc/sys.lua +++ b/modules/luci-base/luasrc/sys.lua @@ -189,6 +189,24 @@ local function _nethints(what, callback) end end ) + + cur:foreach("dhcp", "odhcpd", + function(s) + if type(s.leasefile) == "string" and fs.access(s.leasefile) then + for e in io.lines(s.leasefile) do + duid, iaid, name, _, ip = e:match("^# %S+ (%S+) (%S+) (%S+) (-?%d+) %S+ %S+ ([0-9a-f:.]+)/[0-9]+") + mac = net.duid_to_mac(duid) + if mac then + if ip and iaid == "ipv4" then + _add(what, mac, ip, nil, name ~= "*" and name) + elseif ip then + _add(what, mac, nil, ip, name ~= "*" and name) + end + end + end + end + end + ) cur:foreach("dhcp", "host", function(s) |