luci-app-onliner: merge upstream source

This commit is contained in:
CN_SZTL 2019-12-21 19:07:28 +08:00
parent b28f414468
commit 9eed9b1adf
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
2 changed files with 32 additions and 16 deletions

View File

@ -57,7 +57,18 @@
tbody td {
border-bottom-color: #ccc;
}
tbody td:nth-last-child(4) {
width: 10%;
}
tbody td:nth-last-child(3) {
width: 10%;
}
tbody td:nth-last-child(2) {
width: 10%;
}
tbody td:nth-last-child(1) {
width: 10%;
}
tbody td[rowspan] {
border-bottom-color: #999;
}
@ -373,7 +384,12 @@ function fetchData(period)
for (var i = 0; i < addrs.length; i++)
if (ipAddrs.indexOf(addrs[i].ip) < 0)
ipAddrs.push(addrs[i].ip);
if (hostNames.length == 0){
XHR.get('<%=url("admin/nlbw/ptr")%>/' + ipAddrs.join('/'), null, function(xhr, res) {
if (res !== null && typeof(res) === 'object')
hostNames = res;
});
}
renderHostData();
renderLayer7Data();
renderIPv6Data();
@ -480,7 +496,7 @@ function formatHostname(dns)
dns = dns.split('.')[0];
if (dns.length > 12)
return '<span title="%q">%h…</span>'.format(dns, dns.substr(0, 12));
return '<span title="%q">%q</span>'.format(dns, dns);
return '%h'.format(dns);
}
@ -823,11 +839,11 @@ function bubbleDismiss()
</div>
<table id="host-data">
<tr>
<th width="10%" class="hostname"><%:Host%></th>
<th width="5%"><%:MAC%></th>
<th width="5%"><%:Connections%></th>
<th width="30%" colspan="2"><%:Download (Bytes / Packets)%></th>
<th width="30%" colspan="2"><%:Upload (Bytes / Packets)%></th>
<th width="20%" class="hostname"><%:Host%></th>
<th width="10%"><%:MAC%></th>
<th width="10%"><%:Connections%></th>
<th width="20%" colspan="2"><%:Download (Bytes / Packets)%></th>
<th width="20%" colspan="2"><%:Upload (Bytes / Packets)%></th>
</tr>
</table>
</div>
@ -845,7 +861,7 @@ function bubbleDismiss()
</div>
<table id="layer7-data">
<tr>
<th width="20%"><%:Application%></th>
<th width="10%"><%:Application%></th>
<th width="10%"><%:Connections%></th>
<th width="30%" colspan="2"><%:Download (Bytes / Packets)%></th>
<th width="30%" colspan="2"><%:Upload (Bytes / Packets)%></th>
@ -867,11 +883,11 @@ function bubbleDismiss()
</div>
<table id="ipv6-data">
<tr>
<th width="10%" class="hostname"><%:Host%></th>
<th width="5%"><%:MAC%></th>
<th width="5%"><%:Family%></th>
<th width="40%" colspan="2"><%:Download (Bytes / Packets)%></th>
<th width="40%" colspan="2"><%:Upload (Bytes / Packets)%></th>
<th width="20%" class="hostname"><%:Host%></th>
<th width="10%"><%:MAC%></th>
<th width="10%"><%:Family%></th>
<th width="20%" colspan="2"><%:Download (Bytes / Packets)%></th>
<th width="20%" colspan="2"><%:Upload (Bytes / Packets)%></th>
</tr>
</table>
</div>

View File

@ -8,7 +8,7 @@
local util = require "luci.util"
local function online_data()
local rv = { }
local fd = util.execi("/usr/bin/awk 'NR==FNR{a[$2]=$4}NR!=FNR&&!a[$4]{a[$4]=\"\?\"}NR!=FNR&&/0x[26]/{print a[$4],$1,$4,$6}' /tmp/dhcp.leases /proc/net/arp")
local fd = util.execi('/usr/bin/awk \'BEGIN{while ((getline < "/tmp/dhcp.leases") > 0){a[$2]=$4;}while ((getline < "/proc/net/arp") > 0){if (!a[$4]){a[$4]="\?";}if (match($3,"0x[26]")){"ping -q -c 1 "$1" &";if (b[$4]){b[$4]=b[$4]"/"$1;}else{b[$4]=$1;}c[$4]=$6;}}while (("ip -6 neighbor show | grep -v fe80" | getline) > 0){if (b[$5]) {"ping -q -c 1 "$1" &";b[$5]=b[$5]"/"$1;}}for (mac in b){print(a[mac],b[mac],mac,c[mac]);}}\' ')
while true do
local ln = fd()
if ln == nil then break end
@ -59,7 +59,7 @@ end
tr.className = 'cbi-section-table-row cbi-rowstyle-' + ((i % 2) + 1);
tr.insertCell(-1).innerHTML = info.onlines[i].hostname ? info.onlines[i].hostname : '?';
tr.insertCell(-1).innerHTML = info.onlines[i].ipaddr;
tr.insertCell(-1).innerHTML = info.onlines[i].ipaddr.split("/").join("<br>");
tr.insertCell(-1).innerHTML = info.onlines[i].macaddr;
tr.insertCell(-1).innerHTML = info.onlines[i].device;
}