From 7bbd8d80b4065de231739a1c64cda9d063469a5a Mon Sep 17 00:00:00 2001 From: Joe Uhren Date: Thu, 22 Sep 2022 16:43:01 -0600 Subject: [PATCH] Hide protocols before filter ports on network page -Moved the code around for filtering ports and protocols on the network page to prevent filtering too aggressively when there are multipl entries for an ip address in which the 1st record for a given ip happens to be on a protocol that will be filtered --- views/network.pug | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/views/network.pug b/views/network.pug index c1fde25..7bbfb4a 100644 --- a/views/network.pug +++ b/views/network.pug @@ -32,6 +32,10 @@ block content if (setting_con_port_filter == null || setting_con_port_filter == '') setting_con_port_filter = '-1'; + setting_con_hide_protocols.forEach(function (protocol) { + connectionRows = connectionRows.filter(v => v.protocol != protocol); + }); + if (parseInt(setting_con_port_filter) > 0) connectionRows = connectionRows.filter(v => v.port == setting_con_port_filter); else if (setting_con_port_filter == '-1') { @@ -44,10 +48,6 @@ block content connectionRows = connectionRows.filter((v, i, a) => a.findIndex(t => (t.address === v.address)) === i); } - setting_con_hide_protocols.forEach(function (protocol) { - connectionRows = connectionRows.filter(v => v.protocol != protocol); - }); - var columns = []; if (setting_con_port_filter == '-1') { @@ -121,6 +121,10 @@ block content if (setting_add_port_filter == null || setting_add_port_filter == '') setting_add_port_filter = '-1'; + setting_add_hide_protocols.forEach(function (protocol) { + addNodePeers = addNodePeers.filter(v => v.protocol != protocol); + }); + if (parseInt(setting_add_port_filter) > 0) addNodePeers = addNodePeers.filter(v => v.port == setting_add_port_filter); else if (setting_add_port_filter == '-1') { @@ -133,10 +137,6 @@ block content addNodePeers = addNodePeers.filter((v, i, a) => a.findIndex(t => (t.address === v.address)) === i); } - setting_add_hide_protocols.forEach(function (protocol) { - addNodePeers = addNodePeers.filter(v => v.protocol != protocol); - }); - for (var i = 0; i < addNodePeers.length; i++) addNodeRows.push({'nodes': 'addnode=' + (addNodePeers[i]['address'] != null && addNodePeers[i]['address'].indexOf(':') > -1 ? '[' + addNodePeers[i]['address'] + ']' : addNodePeers[i]['address']) + (addNodePeers[i]['port'] == null ? '' : ':' + addNodePeers[i]['port'])}); @@ -181,6 +181,10 @@ block content if (setting_one_port_filter == null || setting_one_port_filter == '') setting_one_port_filter = '-1'; + setting_one_hide_protocols.forEach(function (protocol) { + peers = peers.filter(v => v.protocol != protocol); + }); + if (parseInt(setting_one_port_filter) > 0) peers = peers.filter(v => v.port == setting_one_port_filter); else if (setting_one_port_filter == '-1') { @@ -193,10 +197,6 @@ block content peers = peers.filter((v, i, a) => a.findIndex(t => (t.address === v.address)) === i); } - setting_one_hide_protocols.forEach(function (protocol) { - peers = peers.filter(v => v.protocol != protocol); - }); - for (var i=0; i < peers.length; i++) oneTryRows.push({'nodes': 'addnode ' + (peers[i]['address'] != null && peers[i]['address'].indexOf(':') > -1 ? '[' + peers[i]['address'] + ']' : peers[i]['address']) + (peers[i]['port'] == null ? '' : ':' + peers[i]['port']) + ' onetry'});