diff options
Diffstat (limited to 'modules/luci-mod-admin-full/luasrc')
-rw-r--r-- | modules/luci-mod-admin-full/luasrc/view/admin_network/lease_status.htm | 28 | ||||
-rw-r--r-- | modules/luci-mod-admin-full/luasrc/view/admin_status/index.htm | 26 |
2 files changed, 50 insertions, 4 deletions
diff --git a/modules/luci-mod-admin-full/luasrc/view/admin_network/lease_status.htm b/modules/luci-mod-admin-full/luasrc/view/admin_network/lease_status.htm index ab8e73257..f7787dd1e 100644 --- a/modules/luci-mod-admin-full/luasrc/view/admin_network/lease_status.htm +++ b/modules/luci-mod-admin-full/luasrc/view/admin_network/lease_status.htm @@ -1,4 +1,18 @@ <script type="text/javascript">//<![CDATA[ + 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 + if (duid.length === 24 && duid.substr(0, 8) === '00030001') + return duid.substr(8).replace(/(..)(?=..)/g, '$1:').toUpperCase(); + + return null; + } + + var hosts = <%=luci.http.write_json(luci.sys.net.host_hints())%>; + XHR.poll(5, '<%=url('admin/network/dhcplease_status')%>', null, function(x, st) { @@ -67,7 +81,17 @@ 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 : '?'; + var host = hosts[duid2mac(st[1][i].duid)]; + if (host) + tr.insertCell(-1).innerHTML = String.format( + '<div style="max-width:200px;overflow:hidden;text-overflow:ellipsis">%s</div>', + ((host.name && (host.ipv4 || host.ipv6)) + ? '%h (%s)'.format(host.name, host.ipv4 || host.ipv6) + : '%h'.format(host.name || host.ipv4 || host.ipv6)).nobr() + ); + else + 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; @@ -106,7 +130,7 @@ <legend><%:Active DHCPv6 Leases%></legend> <table class="cbi-section-table" id="lease6_status_table"> <tr class="cbi-section-table-titles"> - <th class="cbi-section-table-cell"><%:Hostname%></th> + <th class="cbi-section-table-cell"><%:Host%></th> <th class="cbi-section-table-cell"><%:IPv6-Address%></th> <th class="cbi-section-table-cell"><%:DUID%></th> <th class="cbi-section-table-cell"><%:Leasetime remaining%></th> diff --git a/modules/luci-mod-admin-full/luasrc/view/admin_status/index.htm b/modules/luci-mod-admin-full/luasrc/view/admin_status/index.htm index a37982e1d..8bfc61b99 100644 --- a/modules/luci-mod-admin-full/luasrc/view/admin_status/index.htm +++ b/modules/luci-mod-admin-full/luasrc/view/admin_status/index.htm @@ -144,6 +144,18 @@ return s; } + 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 + if (duid.length === 24 && duid.substr(0, 8) === '00030001') + return duid.substr(8).replace(/(..)(?=..)/g, '$1:').toUpperCase(); + + return null; + } + var npoll = 1; var hosts = <%=luci.http.write_json(luci.sys.net.host_hints())%>; @@ -339,7 +351,17 @@ var tr = ls6.rows[0].parentNode.insertRow(-1); tr.className = 'cbi-section-table-row cbi-rowstyle-' + ((i % 2) + 1); - tr.insertCell(-1).innerHTML = info.leases6[i].hostname ? info.leases6[i].hostname : '?'; + var host = hosts[duid2mac(info.leases6[i].duid)]; + if (host) + tr.insertCell(-1).innerHTML = String.format( + '<div style="max-width:200px;overflow:hidden;text-overflow:ellipsis">%s</div>', + ((host.name && (host.ipv4 || host.ipv6)) + ? '%h (%s)'.format(host.name, host.ipv4 || host.ipv6) + : '%h'.format(host.name || host.ipv4 || host.ipv6)).nobr() + ); + else + tr.insertCell(-1).innerHTML = info.leases6[i].hostname ? info.leases6[i].hostname : '?'; + tr.insertCell(-1).innerHTML = info.leases6[i].ip6addr; tr.insertCell(-1).innerHTML = info.leases6[i].duid; tr.insertCell(-1).innerHTML = timestr; @@ -671,7 +693,7 @@ <table class="cbi-section-table" id="lease6_status_table"> <tr class="cbi-section-table-titles"> - <th class="cbi-section-table-cell"><%:Hostname%></th> + <th class="cbi-section-table-cell"><%:Host%></th> <th class="cbi-section-table-cell"><%:IPv6-Address%></th> <th class="cbi-section-table-cell"><%:DUID%></th> <th class="cbi-section-table-cell"><%:Leasetime remaining%></th> |