X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=modules%2Fluci-base%2Fluasrc%2Ftools%2Fstatus.lua;h=4da0cf984b252eef1c344a95be8e1e413bc53c49;hb=a3fc4859dd0d3e9e9fa87ca249b815a4710ed7bd;hp=0dd092c6df42e8681df6911c2074495791efe894;hpb=60f62f841f6816b83dab9a9028c4d0799992c56c;p=oweals%2Fluci.git diff --git a/modules/luci-base/luasrc/tools/status.lua b/modules/luci-base/luasrc/tools/status.lua index 0dd092c6d..4da0cf984 100644 --- a/modules/luci-base/luasrc/tools/status.lua +++ b/modules/luci-base/luasrc/tools/status.lua @@ -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) @@ -48,24 +48,33 @@ local function dhcp_leases_common(family) fd:close() end - local fd = io.open("/tmp/hosts/odhcpd", "r") + local lease6file = "/tmp/hosts/odhcpd" + uci:foreach("dhcp", "odhcpd", + function(t) + if t.leasefile and nfs.access(t.leasefile) then + lease6file = t.leasefile + return false + end + end) + local fd = io.open(lease6file, "r") if fd then while true do local ln = fd:read("*l") if not ln then break else - local iface, duid, iaid, name, ts, id, length, ip = ln:match("^# (%S+) (%S+) (%S+) (%S+) (%d+) (%S+) (%S+) (.*)") + local iface, duid, iaid, name, ts, id, length, ip = ln:match("^# (%S+) (%S+) (%S+) (%S+) (-?%d+) (%S+) (%S+) (.*)") + local expire = tonumber(ts) or 0 if ip and iaid ~= "ipv4" and family == 6 then rv[#rv+1] = { - expires = os.difftime(tonumber(ts) or 0, os.time()), + expires = (expire >= 0) and os.difftime(expire, os.time()), duid = duid, ip6addr = ip, hostname = (name ~= "-") and name } elseif ip and iaid == "ipv4" and family == 4 then rv[#rv+1] = { - expires = os.difftime(tonumber(ts) or 0, os.time()), + expires = (expire >= 0) and os.difftime(expire, os.time()), macaddr = duid, ipaddr = ip, hostname = (name ~= "-") and name