X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fluci.git;a=blobdiff_plain;f=modules%2Fluci-base%2Fluasrc%2Ftools%2Fstatus.lua;h=b0df9d365a03dcccdbb189722530e3f38ddb3aef;hp=a1ecbe71d0ec75adda91cdaca5f588cee2d80845;hb=4fd2b74e4a3463e4538b3bd2ec04e296f24b3825;hpb=51a7f96877d8c5bf70217073ed8aa7ab6a196d20 diff --git a/modules/luci-base/luasrc/tools/status.lua b/modules/luci-base/luasrc/tools/status.lua index a1ecbe71d..b0df9d365 100644 --- a/modules/luci-base/luasrc/tools/status.lua +++ b/modules/luci-base/luasrc/tools/status.lua @@ -63,18 +63,29 @@ local function dhcp_leases_common(family) 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 + local mac, mac1, mac2, mac3, mac4, mac5, mac6 + if duid and type(duid) == "string" then + mac1, mac2, mac3, mac4, mac5, mac6 = duid:match("^(%x%x)(%x%x)(%x%x)(%x%x)(%x%x)(%x%x)$") + end + if not (mac1 and mac2 and mac3 and mac4 and mac5 and mac6) then + mac = "FF:FF:FF:FF:FF:FF" + else + mac = mac1..":"..mac2..":"..mac3..":"..mac4..":"..mac5..":"..mac6 + end rv[#rv+1] = { - expires = os.difftime(tonumber(ts) or 0, os.time()), + expires = (expire >= 0) and os.difftime(expire, os.time()), macaddr = duid, + macaddr = mac:lower(), ipaddr = ip, hostname = (name ~= "-") and name }