diff --git a/modules/admin-core/luasrc/tools/status.lua b/modules/admin-core/luasrc/tools/status.lua
index 2eef3e0e1c..cd543f71e8 100644
--- a/modules/admin-core/luasrc/tools/status.lua
+++ b/modules/admin-core/luasrc/tools/status.lua
@@ -16,7 +16,7 @@ module("luci.tools.status", package.seeall)
local uci = require "luci.model.uci".cursor()
-function dhcp_leases()
+local function dhcp_leases_common(family)
local rv = { }
local nfs = require "nixio.fs"
local leasefile = "/var/dhcp.leases"
@@ -36,14 +36,23 @@ function dhcp_leases()
if not ln then
break
else
- local ts, mac, ip, name = ln:match("^(%d+) (%S+) (%S+) (%S+)")
- if ts and mac and ip and name then
- rv[#rv+1] = {
- expires = os.difftime(tonumber(ts) or 0, os.time()),
- macaddr = mac,
- ipaddr = ip,
- hostname = (name ~= "*") and name
- }
+ local ts, mac, ip, name, duid = ln:match("^(%d+) (%S+) (%S+) (%S+) (%S+)")
+ 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()),
+ 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()),
+ ip6addr = ip,
+ duid = (duid ~= "*") and duid,
+ hostname = (name ~= "*") and name
+ }
+ end
end
end
end
@@ -53,6 +62,18 @@ function dhcp_leases()
return rv
end
+function dhcp_leases()
+ return dhcp_leases_common(4)
+end
+
+function dhcp6_leases()
+ if luci.sys.call("dnsmasq --version 2>/dev/null | grep -q ' DHCPv6 '") == 0 then
+ return dhcp_leases_common(6)
+ else
+ return nil
+ end
+end
+
function wifi_networks()
local rv = { }
local ntm = require "luci.model.network".init()
diff --git a/modules/admin-full/luasrc/controller/admin/network.lua b/modules/admin-full/luasrc/controller/admin/network.lua
index 85d7b18dd5..00e1fe2ff1 100644
--- a/modules/admin-full/luasrc/controller/admin/network.lua
+++ b/modules/admin-full/luasrc/controller/admin/network.lua
@@ -410,7 +410,11 @@ function lease_status()
local s = require "luci.tools.status"
luci.http.prepare_content("application/json")
+ luci.http.write('[')
luci.http.write_json(s.dhcp_leases())
+ luci.http.write(',')
+ luci.http.write_json(s.dhcp6_leases())
+ luci.http.write(']')
end
function diag_command(cmd)
diff --git a/modules/admin-full/luasrc/view/admin_network/lease_status.htm b/modules/admin-full/luasrc/view/admin_network/lease_status.htm
index bf5a5c2677..0ba334ee9d 100644
--- a/modules/admin-full/luasrc/view/admin_network/lease_status.htm
+++ b/modules/admin-full/luasrc/view/admin_network/lease_status.htm
@@ -3,31 +3,31 @@
function(x, st)
{
var tb = document.getElementById('lease_status_table');
- if (st && tb)
+ if (st && st[0] && tb)
{
/* clear all rows */
while( tb.rows.length > 1 )
tb.deleteRow(1);
- for( var i = 0; i < st.length; i++ )
+ for( var i = 0; i < st[0].length; i++ )
{
var timestr;
- if (st[i].expires <= 0)
+ if (st[0][i].expires <= 0)
{
timestr = '<%:expired%>';
}
else
{
- timestr = String.format('%t', st[i].expires);
+ timestr = String.format('%t', st[0][i].expires);
}
var tr = tb.insertRow(-1);
tr.className = 'cbi-section-table-row cbi-rowstyle-' + ((i % 2) + 1);
- tr.insertCell(-1).innerHTML = st[i].hostname ? st[i].hostname : '?';
- tr.insertCell(-1).innerHTML = st[i].ipaddr;
- tr.insertCell(-1).innerHTML = st[i].macaddr;
+ tr.insertCell(-1).innerHTML = st[0][i].hostname ? st[0][i].hostname : '?';
+ tr.insertCell(-1).innerHTML = st[0][i].ipaddr;
+ tr.insertCell(-1).innerHTML = st[0][i].macaddr;
tr.insertCell(-1).innerHTML = timestr;
}
@@ -41,12 +41,54 @@
td.innerHTML = '
<%:There are no active leases.%>';
}
}
+
+ var tb6 = document.getElementById('lease6_status_table');
+ if (st && st[1] && tb6)
+ {
+ tb6.parentNode.style.display = 'block';
+
+ /* clear all rows */
+ while( tb6.rows.length > 1 )
+ tb6.deleteRow(1);
+
+ for( var i = 0; i < st[1].length; i++ )
+ {
+ var timestr;
+
+ if (st[1][i].expires <= 0)
+ {
+ timestr = '<%:expired%>';
+ }
+ else
+ {
+ timestr = String.format('%t', st[1][i].expires);
+ }
+
+ var tr = tb6.insertRow(-1);
+ tr.className = 'cbi-section-table-row cbi-rowstyle-' + ((i % 2) + 1);
+
+ tr.insertCell(-1).innerHTML = st[1][i].hostname ? st[1][i].hostname : '?';
+ tr.insertCell(-1).innerHTML = st[1][i].ip6addr;
+ tr.insertCell(-1).innerHTML = st[1][i].duid;
+ tr.insertCell(-1).innerHTML = timestr;
+ }
+
+ if( tb6.rows.length == 1 )
+ {
+ var tr = tb6.insertRow(-1);
+ tr.className = 'cbi-section-table-row';
+
+ var td = tr.insertCell(-1);
+ td.colSpan = 4;
+ td.innerHTML = '
<%:There are no active leases.%>';
+ }
+ }
}
);
//]]>