From c3f64cd842e05d3a206eb10dbf836e5afa552c1d Mon Sep 17 00:00:00 2001 From: sparks-alec Date: Thu, 5 Jan 2023 02:30:47 -0500 Subject: [PATCH] clearer feedback when too many hosts Instead of preventing search when the subnet is too large, restrict the search area to part of the subnet and provide feedback about which hosts are to be searched. --- networkInterfaces.html | 8 +++++++- networkInterfaces.js | 9 ++++++++- preload.js | 1 - src/search.js | 15 ++++++++++++--- 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/networkInterfaces.html b/networkInterfaces.html index c9f0a6a..1821f3b 100644 --- a/networkInterfaces.html +++ b/networkInterfaces.html @@ -66,6 +66,12 @@ .if-ut { background-color: #bf360c; } + .red { + color: #ca6f1e; + } + .green { + color: #28b463; + } @@ -76,7 +82,7 @@ ID IP Address Subnet Mask - Searchable Addresses + Searchable Address Ranges diff --git a/networkInterfaces.js b/networkInterfaces.js index 9551fc7..3da71b8 100644 --- a/networkInterfaces.js +++ b/networkInterfaces.js @@ -12,7 +12,14 @@ window.init = function init() { html += `${interfaceID}`; html += `${interfaceObj[0].address}`; html += `${interfaceObj[0].netmask}`; - html += `${interfaceObj[0].firstSearchAddress} - ${interfaceObj[0].lastSearchAddress}`; + + if (interfaceObj[0].searchTruncated) { + html += ``; + } else { + html += ``; + } + + html += `${interfaceObj[0].firstSearchAddress} - ${interfaceObj[0].lastSearchAddress}`; html += ``; document.getElementById('network-interfaces').innerHTML = html; diff --git a/preload.js b/preload.js index 11937c8..8464370 100644 --- a/preload.js +++ b/preload.js @@ -108,7 +108,6 @@ window.init = function init() { document.getElementById('network-info-button').onclick = function fooBar(e) { ipcRenderer.send('openNetworkInfoWindow'); - console.log('FOO'); }; document.onkeyup = function keyUp(e) { diff --git a/src/search.js b/src/search.js index 57fe5da..9367510 100644 --- a/src/search.js +++ b/src/search.js @@ -23,10 +23,19 @@ function getServers() { for (let i = addresses.length; i--; ) { const address = addresses[i]; if (address.family === 'IPv4' && !address.internal && address.address.substring(0, 3) !== '169') { - const subnet = ip.subnet(address.address, address.netmask); + let subnet = ip.subnet(address.address, address.netmask); let current = ip.toLong(subnet.firstAddress); - const last = ip.toLong(subnet.lastAddress) - 1; + let last = ip.toLong(subnet.lastAddress) - 1; + address.searchTruncated = false; + + if (last - current > 2296) { + subnet = ip.subnet(address.address, '255.255.248.0'); + last = ip.toLong(subnet.lastAddress) - 1; + address.searchTruncated = true; + } + // console.log(`range ${subnet.firstAddress} - ${subnet.lastAddress}`); + address.broadcastAddress = subnet.broadcastAddress; address.firstSearchAddress = subnet.firstAddress; address.lastSearchAddress = subnet.lastAddress; @@ -59,7 +68,7 @@ function searchAll() { console.log('Searching...'); allServers = getServers(); let TCPFlag = true; - if (allServers.length > 2046) { + if (allServers.length > 2296) { alert( 'Unable to search for TCP devices - subnet too large!\n\nCue View requires subnet 255.255.248.0 (/21) or smaller.' );