1 <script type=
"text/javascript">//<![CDATA[
2 function duid2mac(duid) {
4 if (duid.length ===
28 && duid.substr(
0,
8) === '
00010001')
5 return duid.substr(
16).replace(/(..)(?=..)/g, '$
1:').toUpperCase();
8 if (duid.length ===
20 && duid.substr(
0,
8) === '
00030001')
9 return duid.substr(
8).replace(/(..)(?=..)/g, '$
1:').toUpperCase();
14 var hosts = <%=luci.http.write_json(luci.sys.net.host_hints())%
>;
16 XHR.poll(
5, '<%=url('admin/network/dhcplease_status')%
>', null,
19 var tb = document.getElementById('lease_status_table');
20 if (st && st[
0] && tb)
23 while( tb.rows.length
> 1 )
26 for( var i =
0; i < st[
0].length; i++ )
30 if (st[
0][i].expires === false)
31 timestr = '
<em><%:unlimited%
></em>';
32 else if (st[
0][i].expires <=
0)
33 timestr = '
<em><%:expired%
></em>';
35 timestr = String.format('%t', st[
0][i].expires);
37 var tr = tb.insertRow(-
1);
38 tr.className = 'cbi-section-table-row cbi-rowstyle-' + ((i %
2) +
1);
40 tr.insertCell(-
1).innerHTML = st[
0][i].hostname ? st[
0][i].hostname : '?';
41 tr.insertCell(-
1).innerHTML = st[
0][i].ipaddr;
42 tr.insertCell(-
1).innerHTML = st[
0][i].macaddr;
43 tr.insertCell(-
1).innerHTML = timestr;
46 if( tb.rows.length ==
1 )
48 var tr = tb.insertRow(-
1);
49 tr.className = 'cbi-section-table-row';
51 var td = tr.insertCell(-
1);
53 td.innerHTML = '
<em><br /><%:There are no active leases.%
></em>';
57 var tb6 = document.getElementById('lease6_status_table');
58 if (st && st[
1] && tb6)
60 tb6.parentNode.style.display = 'block';
63 while( tb6.rows.length
> 1 )
66 for( var i =
0; i < st[
1].length; i++ )
70 if (st[
1][i].expires === false)
71 timestr = '
<em><%:unlimited%
></em>';
72 else if (st[
1][i].expires <=
0)
73 timestr = '
<em><%:expired%
></em>';
75 timestr = String.format('%t', st[
1][i].expires);
77 var tr = tb6.insertRow(-
1);
78 tr.className = 'cbi-section-table-row cbi-rowstyle-' + ((i %
2) +
1);
80 var host = hosts[duid2mac(st[
1][i].duid)];
81 if (!st[
1][i].hostname)
82 tr.insertCell(-
1).innerHTML =
83 (host && (host.name || host.ipv4 || host.ipv6))
84 ? '
<div style=
"max-width:200px;overflow:hidden;text-overflow:ellipsis;white-space: nowrap">? (%h)
</div>'.format(host.name || host.ipv4 || host.ipv6)
87 tr.insertCell(-
1).innerHTML =
88 (host && host.name && st[
1][i].hostname != host.name)
89 ? '
<div style=
"max-width:200px;overflow:hidden;text-overflow:ellipsis;white-space: nowrap">%h (%h)
</div>'.format(st[
1][i].hostname, host.name)
92 tr.insertCell(-
1).innerHTML = st[
1][i].ip6addr;
93 tr.insertCell(-
1).innerHTML = st[
1][i].duid;
94 tr.insertCell(-
1).innerHTML = timestr;
97 if( tb6.rows.length ==
1 )
99 var tr = tb6.insertRow(-
1);
100 tr.className = 'cbi-section-table-row';
102 var td = tr.insertCell(-
1);
104 td.innerHTML = '
<em><br /><%:There are no active leases.%
></em>';
111 <fieldset class=
"cbi-section">
112 <legend><%:Active DHCP Leases%
></legend>
113 <table class=
"cbi-section-table" id=
"lease_status_table">
114 <tr class=
"cbi-section-table-titles">
115 <th class=
"cbi-section-table-cell"><%:Hostname%
></th>
116 <th class=
"cbi-section-table-cell"><%:IPv4-Address%
></th>
117 <th class=
"cbi-section-table-cell"><%:MAC-Address%
></th>
118 <th class=
"cbi-section-table-cell"><%:Leasetime remaining%
></th>
120 <tr class=
"cbi-section-table-row">
121 <td colspan=
"4"><em><br /><%:Collecting data...%
></em></td>
126 <fieldset class=
"cbi-section" style=
"display:none">
127 <legend><%:Active DHCPv6 Leases%
></legend>
128 <table class=
"cbi-section-table" id=
"lease6_status_table">
129 <tr class=
"cbi-section-table-titles">
130 <th class=
"cbi-section-table-cell"><%:Host%
></th>
131 <th class=
"cbi-section-table-cell"><%:IPv6-Address%
></th>
132 <th class=
"cbi-section-table-cell"><%:DUID%
></th>
133 <th class=
"cbi-section-table-cell"><%:Leasetime remaining%
></th>
135 <tr class=
"cbi-section-table-row">
136 <td colspan=
"4"><em><br /><%:Collecting data...%
></em></td>