summaryrefslogtreecommitdiffhomepage
path: root/modules/admin-core
diff options
context:
space:
mode:
authorSteven Barth <steven@midlink.org>2013-05-23 10:14:20 +0000
committerSteven Barth <steven@midlink.org>2013-05-23 10:14:20 +0000
commit5200eb1577777766a831bdcbb76ce8769af0da08 (patch)
tree49368ab6f215476fde10a4716823e358ddc64f4f /modules/admin-core
parent029631ec489b2d28a9e4b3a6ef4f2de9e999b956 (diff)
Add support for stateful DHCPv6
Diffstat (limited to 'modules/admin-core')
-rw-r--r--modules/admin-core/luasrc/tools/status.lua30
1 files changed, 27 insertions, 3 deletions
diff --git a/modules/admin-core/luasrc/tools/status.lua b/modules/admin-core/luasrc/tools/status.lua
index 3ececa8f1..becd7d465 100644
--- a/modules/admin-core/luasrc/tools/status.lua
+++ b/modules/admin-core/luasrc/tools/status.lua
@@ -66,10 +66,34 @@ function dhcp_leases()
end
function dhcp6_leases()
- if luci.sys.call("dnsmasq --version 2>/dev/null | grep -q ' DHCPv6 '") == 0 then
+ local nfs = require "nixio.fs"
+ local leasefile = "/tmp/hosts/6relayd"
+ local rv = {}
+
+ if nfs.access(leasefile, "r") then
+ local fd = io.open(leasefile, "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+) (.*)")
+ if ip then
+ rv[#rv+1] = {
+ expires = os.difftime(tonumber(ts) or 0, os.time()),
+ duid = duid,
+ ip6addr = ip,
+ hostname = (name ~= "-") and name
+ }
+ end
+ end
+ end
+ fd:close()
+ end
+ return rv
+ elseif luci.sys.call("dnsmasq --version 2>/dev/null | grep -q ' DHCPv6 '") == 0 then
return dhcp_leases_common(6)
- else
- return nil
end
end