summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-base
diff options
context:
space:
mode:
authorCody R. Brown <dev@codybrown.ca>2017-01-22 22:25:44 -0800
committerJo-Philipp Wich <jo@mein.io>2017-06-01 00:17:32 +0200
commite5ed0e7e78143a039213bc311f91a220083b2930 (patch)
tree678f1da1f8e9a62c3201e2332d3e0cdcd4c2bbb4 /modules/luci-base
parentdbc1a1bfc1be95b64062eaa1edb122288d5ab201 (diff)
luci-base: luci.tools.status: properly parse infinite dnsmasq leases
The expiry time in a dnsmasq lease file line may be 0 (i.e. expiry date = 01/01/1970 00:00:00 GMT) 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. This is to mimic the odhcp code below. If the expiry date is not equal to 0, then just do exactly what was done before (return the os.diff of current time and ts). Signed-off-by: Cody R. Brown <dev@codybrown.ca>
Diffstat (limited to 'modules/luci-base')
-rw-r--r--modules/luci-base/luasrc/tools/status.lua5
1 files changed, 3 insertions, 2 deletions
diff --git a/modules/luci-base/luasrc/tools/status.lua b/modules/luci-base/luasrc/tools/status.lua
index b0df9d365..95ff46df1 100644
--- a/modules/luci-base/luasrc/tools/status.lua
+++ b/modules/luci-base/luasrc/tools/status.lua
@@ -26,17 +26,18 @@ local function dhcp_leases_common(family)
break
else
local ts, mac, ip, name, duid = ln:match("^(%d+) (%S+) (%S+) (%S+) (%S+)")
+ local expire = tonumber(ts) or 0
if ts and mac and ip and name and duid then
if family == 4 and not ip:match(":") then
rv[#rv+1] = {
- expires = os.difftime(tonumber(ts) or 0, os.time()),
+ expires = (expire ~= 0) and os.difftime(expire, os.time()),
macaddr = mac,
ipaddr = ip,
hostname = (name ~= "*") and name
}
elseif family == 6 and ip:match(":") then
rv[#rv+1] = {
- expires = os.difftime(tonumber(ts) or 0, os.time()),
+ expires = (expire ~= 0) and os.difftime(expire, os.time()),
ip6addr = ip,
duid = (duid ~= "*") and duid,
hostname = (name ~= "*") and name