summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2016-12-09 13:05:44 +0100
committerJo-Philipp Wich <jo@mein.io>2016-12-09 13:05:44 +0100
commit8e9e92a630a9e18eef642c02b8a7fa476440ab37 (patch)
treebe42a7cf6591e76607bc31203c964f16e1bc2bc8
parent6d5f878d7c993f08e4fb48efba169f7bb4869e6f (diff)
luci-base: luci.tools.status: properly parse infinite odhcpd leases
The expiry time in an odhcpd lease file line may be -1 to denote an infinite lease time, so adjust the code to properly support that. The expiry attribute of the lease object will be set to "false" in case of an infinite lease. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
-rw-r--r--modules/luci-base/luasrc/tools/status.lua7
1 files changed, 4 insertions, 3 deletions
diff --git a/modules/luci-base/luasrc/tools/status.lua b/modules/luci-base/luasrc/tools/status.lua
index a1ecbe71d0..4da0cf984b 100644
--- a/modules/luci-base/luasrc/tools/status.lua
+++ b/modules/luci-base/luasrc/tools/status.lua
@@ -63,17 +63,18 @@ 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
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