2010-11-18 01:34:56 +00:00
|
|
|
<script type="text/javascript">//<![CDATA[
|
2016-01-25 16:54:38 +00:00
|
|
|
function duid2mac(duid) {
|
|
|
|
// DUID-LLT / Ethernet
|
|
|
|
if (duid.length === 28 && duid.substr(0, 8) === '00010001')
|
|
|
|
return duid.substr(16).replace(/(..)(?=..)/g, '$1:').toUpperCase();
|
|
|
|
|
|
|
|
// DUID-LL / Ethernet
|
2017-12-08 09:55:18 +00:00
|
|
|
if (duid.length === 20 && duid.substr(0, 8) === '00030001')
|
2016-01-25 16:54:38 +00:00
|
|
|
return duid.substr(8).replace(/(..)(?=..)/g, '$1:').toUpperCase();
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
var hosts = <%=luci.http.write_json(luci.sys.net.host_hints())%>;
|
|
|
|
|
2015-10-07 17:07:36 +00:00
|
|
|
XHR.poll(5, '<%=url('admin/network/dhcplease_status')%>', null,
|
2011-09-26 00:24:34 +00:00
|
|
|
function(x, st)
|
|
|
|
{
|
|
|
|
var tb = document.getElementById('lease_status_table');
|
2012-08-17 15:06:46 +00:00
|
|
|
if (st && st[0] && tb)
|
2010-11-07 23:31:19 +00:00
|
|
|
{
|
2011-09-26 00:24:34 +00:00
|
|
|
/* clear all rows */
|
2018-05-28 12:57:54 +00:00
|
|
|
while (tb.firstElementChild !== tb.lastElementChild)
|
|
|
|
tb.removeChild(tb.lastElementChild);
|
2011-09-26 00:24:34 +00:00
|
|
|
|
2018-05-28 12:57:54 +00:00
|
|
|
for (var i = 0; i < st[0].length; i++)
|
2010-11-07 23:31:19 +00:00
|
|
|
{
|
2011-09-26 00:24:34 +00:00
|
|
|
var timestr;
|
2010-11-07 23:31:19 +00:00
|
|
|
|
2016-12-09 12:07:42 +00:00
|
|
|
if (st[0][i].expires === false)
|
|
|
|
timestr = '<em><%:unlimited%></em>';
|
|
|
|
else if (st[0][i].expires <= 0)
|
2011-09-26 00:24:34 +00:00
|
|
|
timestr = '<em><%:expired%></em>';
|
|
|
|
else
|
2012-08-17 15:06:46 +00:00
|
|
|
timestr = String.format('%t', st[0][i].expires);
|
2011-09-26 00:24:34 +00:00
|
|
|
|
2018-06-19 15:17:04 +00:00
|
|
|
tb.appendChild(E('<div class="tr cbi-rowstyle-%d">'.format((i % 2) + 1), [
|
2018-05-28 12:57:54 +00:00
|
|
|
E('<div class="td">', st[0][i].hostname || '?'),
|
|
|
|
E('<div class="td">', st[0][i].ipaddr),
|
|
|
|
E('<div class="td">', st[0][i].macaddr),
|
|
|
|
E('<div class="td">', timestr)
|
|
|
|
]));
|
2010-11-07 23:31:19 +00:00
|
|
|
}
|
2010-11-17 15:23:21 +00:00
|
|
|
|
2018-05-28 12:57:54 +00:00
|
|
|
if (tb.firstElementChild === tb.lastElementChild)
|
2018-06-19 15:17:04 +00:00
|
|
|
tb.appendChild(E('<div class="tr"><div class="td"><em><br /><%:There are no active leases.%></em></div></div>'));
|
2010-11-07 23:31:19 +00:00
|
|
|
}
|
2012-08-17 15:06:46 +00:00
|
|
|
|
|
|
|
var tb6 = document.getElementById('lease6_status_table');
|
|
|
|
if (st && st[1] && tb6)
|
|
|
|
{
|
|
|
|
tb6.parentNode.style.display = 'block';
|
|
|
|
|
|
|
|
/* clear all rows */
|
2018-05-28 12:57:54 +00:00
|
|
|
while (tb6.firstElementChild !== tb6.lastElementChild)
|
|
|
|
tb6.removeChild(tb6.lastElementChild);
|
2012-08-17 15:06:46 +00:00
|
|
|
|
2018-05-28 12:57:54 +00:00
|
|
|
for (var i = 0; i < st[1].length; i++)
|
2012-08-17 15:06:46 +00:00
|
|
|
{
|
|
|
|
var timestr;
|
|
|
|
|
2016-12-09 12:07:42 +00:00
|
|
|
if (st[1][i].expires === false)
|
|
|
|
timestr = '<em><%:unlimited%></em>';
|
|
|
|
else if (st[1][i].expires <= 0)
|
2012-08-17 15:06:46 +00:00
|
|
|
timestr = '<em><%:expired%></em>';
|
|
|
|
else
|
|
|
|
timestr = String.format('%t', st[1][i].expires);
|
|
|
|
|
2018-05-28 12:57:54 +00:00
|
|
|
var host = hosts[duid2mac(st[1][i].duid)],
|
|
|
|
name = st[1][i].hostname,
|
|
|
|
hint = null;
|
|
|
|
|
|
|
|
if (!name) {
|
|
|
|
if (host)
|
|
|
|
hint = host.name || host.ipv4 || host.ipv6;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (host && host.name && st[1][i].hostname != host.name)
|
|
|
|
hint = host.name;
|
|
|
|
}
|
|
|
|
|
2018-06-19 15:17:04 +00:00
|
|
|
tb6.appendChild(E('<div class="tr cbi-rowstyle-%d">'.format((i % 2) + 1), [
|
|
|
|
E('<div class="td nowrap">', hint ? '%h (%h)'.format(name || '?', hint) : (name || '?')),
|
2018-05-28 12:57:54 +00:00
|
|
|
E('<div class="td">', st[1][i].ip6addr),
|
|
|
|
E('<div class="td">', st[1][i].duid),
|
|
|
|
E('<div class="td">', timestr)
|
|
|
|
]));
|
2012-08-17 15:06:46 +00:00
|
|
|
}
|
|
|
|
|
2018-05-28 12:57:54 +00:00
|
|
|
if (tb6.firstElementChild === tb6.lastElementChild)
|
2018-06-19 15:17:04 +00:00
|
|
|
tb6.appendChild(E('<div class="tr"><div class="td"><em><br /><%:There are no active leases.%></em></div></div>'));
|
2012-08-17 15:06:46 +00:00
|
|
|
}
|
2011-09-26 00:24:34 +00:00
|
|
|
}
|
|
|
|
);
|
2010-11-18 01:34:56 +00:00
|
|
|
//]]></script>
|
2010-11-07 23:31:19 +00:00
|
|
|
|
|
|
|
<fieldset class="cbi-section">
|
2012-08-17 15:06:46 +00:00
|
|
|
<legend><%:Active DHCP Leases%></legend>
|
2018-06-19 15:17:04 +00:00
|
|
|
<div class="table" id="lease_status_table">
|
|
|
|
<div class="tr">
|
|
|
|
<div class="th"><%:Hostname%></div>
|
|
|
|
<div class="th"><%:IPv4-Address%></div>
|
|
|
|
<div class="th"><%:MAC-Address%></div>
|
|
|
|
<div class="th"><%:Leasetime remaining%></div>
|
2018-05-28 12:57:54 +00:00
|
|
|
</div>
|
2018-06-19 15:17:04 +00:00
|
|
|
<div class="tr">
|
2018-05-28 12:57:54 +00:00
|
|
|
<div class="td" colspan="4"><em><br /><%:Collecting data...%></em></div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2010-11-07 23:31:19 +00:00
|
|
|
</fieldset>
|
2012-08-17 15:06:46 +00:00
|
|
|
|
|
|
|
<fieldset class="cbi-section" style="display:none">
|
|
|
|
<legend><%:Active DHCPv6 Leases%></legend>
|
2018-06-19 15:17:04 +00:00
|
|
|
<div class="table" id="lease6_status_table">
|
|
|
|
<div class="tr">
|
|
|
|
<div class="th"><%:Host%></div>
|
|
|
|
<div class="th"><%:IPv6-Address%></div>
|
|
|
|
<div class="th"><%:DUID%></div>
|
|
|
|
<div class="th"><%:Leasetime remaining%></div>
|
2018-05-28 12:57:54 +00:00
|
|
|
</div>
|
2018-06-19 15:17:04 +00:00
|
|
|
<div class="tr">
|
2018-05-28 12:57:54 +00:00
|
|
|
<div class="td" colspan="4"><em><br /><%:Collecting data...%></em></div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2012-08-17 15:06:46 +00:00
|
|
|
</fieldset>
|