summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorFlorian Eckert <fe@dev.tdt.de>2019-06-28 07:49:37 +0200
committerGitHub <noreply@github.com>2019-06-28 07:49:37 +0200
commit977f657791cc550f0fffa6e35948bbdf537c520d (patch)
tree485a56053813f1a44ea5366a551b3734dc7e616d
parentae1652fc116f542dcefba275d1e7d2f9c6564e12 (diff)
parente8bce3db42e259f25476e8e953dfe8ae605d3fcd (diff)
Merge pull request #2061 from Ansuel/improveconn
luci-mod-admin-full: improve connection page lookup loop
-rw-r--r--modules/luci-mod-status/luasrc/view/admin_status/connections.htm51
1 files changed, 41 insertions, 10 deletions
diff --git a/modules/luci-mod-status/luasrc/view/admin_status/connections.htm b/modules/luci-mod-status/luasrc/view/admin_status/connections.htm
index e3dd39d60..37debcde6 100644
--- a/modules/luci-mod-status/luasrc/view/admin_status/connections.htm
+++ b/modules/luci-mod-status/luasrc/view/admin_status/connections.htm
@@ -131,15 +131,21 @@
}
label_scale.innerHTML = String.format('<%:(%d minute window, %d second interval)%>', data_wanted / 60, 3);
+
+ var recheck_lookup_queue = {};
/* render datasets, start update interval */
XHR.poll(3, '<%=build_url("admin/status/realtime/connections_status")%>', null,
function(x, json)
{
- var rows = [];
+
+ if (!json.connections)
+ return;
+
var conn = json.connections;
var lookup_queue = [ ];
+ var rows = [];
conn.sort(function(a, b) {
return b.bytes - a.bytes;
@@ -150,13 +156,13 @@
var c = conn[i];
if ((c.src == '127.0.0.1' && c.dst == '127.0.0.1') ||
- (c.src == '::1' && c.dst == '::1'))
+ (c.src == '::1' && c.dst == '::1'))
continue;
- if (!dns_cache[c.src])
+ if (!dns_cache[c.src] && lookup_queue.indexOf(c.src) == -1)
lookup_queue.push(c.src);
- if (!dns_cache[c.dst])
+ if (!dns_cache[c.dst] && lookup_queue.indexOf(c.dst) == -1)
lookup_queue.push(c.dst);
var src = dns_cache[c.src] || (c.layer3 == 'ipv6' ? '[' + c.src + ']' : c.src);
@@ -173,14 +179,39 @@
cbi_update_table(conn_table, rows, '<em><%:No information available%></em>');
- if (lookup_queue.length > 0)
- XHR.get('<%=build_url("admin/status/nameinfo")%>/' + lookup_queue.slice(0, 100).join('/'), null,
- function(x, json)
- {
- for (var addr in json)
- dns_cache[addr] = json[addr];
+ if (lookup_queue.length > 0) {
+ var reduced_lookup_queue = lookup_queue;
+
+ if (lookup_queue.length > 100)
+ reduced_lookup_queue = lookup_queue.slice(0, 100);
+
+ XHR.get('<%=build_url("admin/status/nameinfo")%>/' + reduced_lookup_queue.join('/'), null,
+ function(x, json) {
+ if (!json)
+ return;
+
+ for (var index in reduced_lookup_queue) {
+ var address = reduced_lookup_queue[index];
+
+ if (!address)
+ continue;
+
+ if (json[address]) {
+ dns_cache[address] = json[address];
+ lookup_queue.splice(reduced_lookup_queue.indexOf(address),1);
+ continue;
+ }
+
+ if(recheck_lookup_queue[address] > 2) {
+ dns_cache[address] = (address.match(/:/)) ? '[' + address + ']' : address;
+ lookup_queue.splice(index,1);
+ } else {
+ recheck_lookup_queue[address] != null ? recheck_lookup_queue[address]++ : recheck_lookup_queue[address] = 0;
+ }
+ }
}
);
+ }
var data = json.statistics;