From e3b18a0f7567e00cba3458f6a6359bd32ae20c42 Mon Sep 17 00:00:00 2001 From: JuanCamp Date: Mon, 7 Oct 2019 15:29:13 -0500 Subject: [PATCH 01/37] Add DHCP Status and connection DNS suffix search order --- lib/network.js | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/lib/network.js b/lib/network.js index 457fc16..7887708 100644 --- a/lib/network.js +++ b/lib/network.js @@ -183,19 +183,29 @@ exports.networkInterfaceDefault = networkInterfaceDefault; // -------------------------- // NET - interfaces -function parseLinesWindowsNics(sections) { +function parseLinesWindowsNics(sections, nconfigsections) { let nics = []; for (let i in sections) { if (sections.hasOwnProperty(i)) { + if (sections[i].trim() !== '') { - + let lines = sections[i].trim().split('\r\n'); + let linesNicConfig = nconfigsections[i].trim().split('\r\n'); let netEnabled = util.getValue(lines, 'NetEnabled', '='); + let dnsSuffixes = util.getValue(linesNicConfig, 'DNSDomainSuffixSearchOrder', '=').replace(/{|}/g, ''); + if(dnsSuffixes !== '') { + dnsSuffixes = dnsSuffixes.replace(/;/g, ','); + dnsSuffixes = dnsSuffixes.split(","); + } + if (netEnabled) { const speed = parseInt(util.getValue(lines, 'speed', '=').trim(), 10) / 1000000; nics.push({ mac: util.getValue(lines, 'MACAddress', '=').toLowerCase(), + dhcp: util.getValue(linesNicConfig, 'dhcpEnabled', '=').toLowerCase(), name: util.getValue(lines, 'Name', '=').replace(/\]/g, ')').replace(/\[/g, '('), + dnsSuffixes: dnsSuffixes === '' ? [] : dnsSuffixes, netEnabled: netEnabled === 'TRUE', speed: isNaN(speed) ? -1 : speed, operstate: util.getValue(lines, 'NetConnectionStatus', '=') === '2' ? 'up' : 'down', @@ -210,9 +220,11 @@ function parseLinesWindowsNics(sections) { function getWindowsNics() { const cmd = util.getWmic() + ' nic get MACAddress, name, NetEnabled, Speed, NetConnectionStatus, AdapterTypeId /value'; + const cmdnicconfig = util.getWmic() + ' nicconfig get dhcpEnabled, DNSDomainSuffixSearchOrder /value'; try { const nsections = execSync(cmd, util.execOptsWin).split(/\n\s*\n/); - return (parseLinesWindowsNics(nsections)); + const nconfigsections = execSync(cmdnicconfig, util.execOptsWin).split(/\n\s*\n/); + return (parseLinesWindowsNics(nsections, nconfigsections)); } catch (e) { return []; } @@ -373,12 +385,13 @@ function networkInterfaces(callback) { let speed = -1; let carrierChanges = 0; let operstate = 'down'; + let dhcp = false; + let dnsSuffixes = []; let type = ''; if (ifaces.hasOwnProperty(dev)) { let ifaceName = dev; ifaces[dev].forEach(function (details) { - if (details.family === 'IPv4') { ip4 = details.address; } @@ -426,6 +439,7 @@ function networkInterfaces(callback) { let lines = []; try { lines = execSync(cmd).toString().split('\n'); + } catch (e) { util.noop(); } @@ -448,6 +462,8 @@ function networkInterfaces(callback) { nics.forEach(detail => { if (detail.mac === mac) { ifaceName = detail.name; + dhcp = detail.dhcp; + dnsSuffixes = detail.dnsSuffixes; operstate = detail.operstate; speed = detail.speed; type = detail.type; @@ -472,6 +488,8 @@ function networkInterfaces(callback) { duplex, mtu, speed, + dhcp, + dnsSuffixes, carrierChanges, }); } From 40bdd6fc11cd283884f78537a4b347cf7b2678ac Mon Sep 17 00:00:00 2001 From: juancampuzano <52759609+juancampuzano@users.noreply.github.com> Date: Wed, 9 Oct 2019 13:29:19 -0500 Subject: [PATCH 02/37] Return without quatation marks --- lib/network.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/network.js b/lib/network.js index 7887708..8be1323 100644 --- a/lib/network.js +++ b/lib/network.js @@ -196,6 +196,7 @@ function parseLinesWindowsNics(sections, nconfigsections) { let dnsSuffixes = util.getValue(linesNicConfig, 'DNSDomainSuffixSearchOrder', '=').replace(/{|}/g, ''); if(dnsSuffixes !== '') { dnsSuffixes = dnsSuffixes.replace(/;/g, ','); + dnsSuffixes = dnsSuffixes.replace(/"/g, ''); dnsSuffixes = dnsSuffixes.split(","); } From 73a2ad62b1a78c17048a8c14f99952fe78146f2c Mon Sep 17 00:00:00 2001 From: ricardopolo Date: Wed, 30 Oct 2019 17:40:40 -0500 Subject: [PATCH 03/37] get DHCP status in linux --- lib/network.js | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/lib/network.js b/lib/network.js index 8be1323..11c0d5f 100644 --- a/lib/network.js +++ b/lib/network.js @@ -317,6 +317,31 @@ function getDarwinNics() { } } + +function getNicDHCPstatus(interfaceName) { + const cmd = `nmcli con sh "${interfaceName}" | grep ipv4.method`; + console.log(cmd); + try { + let dhcpStatus = ""; + const lines = execSync(cmd, util.execOptsWin).toString().split('\n'); + const nsections = splitSectionsNics(lines); + console.log(nsections); + switch (key) { + case "auto": + dhcpStatus = "true"; + break; + + default: + dhcpStatus = "false"; + break; + } + return dhcpStatus; + } catch (e) { + return []; + } +} + + function testVirtualNic(iface, ifaceName, mac) { const virtualMacs = ['00:00:00:00:00:00', '00:03:FF', '00:05:69', '00:0C:29', '00:0F:4B', '00:0F:4B', '00:13:07', '00:13:BE', '00:15:5d', '00:16:3E', '00:1C:42', '00:21:F6', '00:21:F6', '00:24:0B', '00:24:0B', '00:50:56', '00:A0:B1', '00:E0:C8', '08:00:27', '0A:00:27', '18:92:2C', '16:DF:49', '3C:F3:92', '54:52:00', 'FC:15:97']; if (mac) { @@ -342,11 +367,11 @@ function networkInterfaces(callback) { // seperate handling in OSX if (_darwin || _freebsd || _openbsd || _netbsd) { nics = getDarwinNics(); - // console.log(nics); - // console.log('-------'); - // console.log(ifaces); + nics.forEach(nic => { + dhcpStatus = getNicDHCPstatus(nic.iface); + result.push({ iface: nic.iface, ifaceName: nic.iface, @@ -358,6 +383,7 @@ function networkInterfaces(callback) { operstate: nic.operstate, type: nic.type, duplex: nic.duplex, + dhcpStatus: dhcpStatus, mtu: nic.mtu, speed: nic.speed, carrierChanges: 0 From f32233fee81c4158372b09fde38f1e7082b07763 Mon Sep 17 00:00:00 2001 From: ricardopolo Date: Fri, 1 Nov 2019 10:12:33 -0500 Subject: [PATCH 04/37] Do not use DNSSuffixes from windows --- lib/network.js | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/lib/network.js b/lib/network.js index 11c0d5f..f8c9153 100644 --- a/lib/network.js +++ b/lib/network.js @@ -193,12 +193,6 @@ function parseLinesWindowsNics(sections, nconfigsections) { let lines = sections[i].trim().split('\r\n'); let linesNicConfig = nconfigsections[i].trim().split('\r\n'); let netEnabled = util.getValue(lines, 'NetEnabled', '='); - let dnsSuffixes = util.getValue(linesNicConfig, 'DNSDomainSuffixSearchOrder', '=').replace(/{|}/g, ''); - if(dnsSuffixes !== '') { - dnsSuffixes = dnsSuffixes.replace(/;/g, ','); - dnsSuffixes = dnsSuffixes.replace(/"/g, ''); - dnsSuffixes = dnsSuffixes.split(","); - } if (netEnabled) { const speed = parseInt(util.getValue(lines, 'speed', '=').trim(), 10) / 1000000; @@ -206,7 +200,6 @@ function parseLinesWindowsNics(sections, nconfigsections) { mac: util.getValue(lines, 'MACAddress', '=').toLowerCase(), dhcp: util.getValue(linesNicConfig, 'dhcpEnabled', '=').toLowerCase(), name: util.getValue(lines, 'Name', '=').replace(/\]/g, ')').replace(/\[/g, '('), - dnsSuffixes: dnsSuffixes === '' ? [] : dnsSuffixes, netEnabled: netEnabled === 'TRUE', speed: isNaN(speed) ? -1 : speed, operstate: util.getValue(lines, 'NetConnectionStatus', '=') === '2' ? 'up' : 'down', @@ -413,7 +406,6 @@ function networkInterfaces(callback) { let carrierChanges = 0; let operstate = 'down'; let dhcp = false; - let dnsSuffixes = []; let type = ''; if (ifaces.hasOwnProperty(dev)) { @@ -490,7 +482,6 @@ function networkInterfaces(callback) { if (detail.mac === mac) { ifaceName = detail.name; dhcp = detail.dhcp; - dnsSuffixes = detail.dnsSuffixes; operstate = detail.operstate; speed = detail.speed; type = detail.type; @@ -516,7 +507,6 @@ function networkInterfaces(callback) { mtu, speed, dhcp, - dnsSuffixes, carrierChanges, }); } From fca0920652a4735f6fb4fac08290d9f4489221d1 Mon Sep 17 00:00:00 2001 From: VP-002 U <> Date: Fri, 1 Nov 2019 10:13:18 -0500 Subject: [PATCH 05/37] get dhcp status from linux --- lib/network.js | 54 +++++++++++++++++++++++++++++++++----------------- 1 file changed, 36 insertions(+), 18 deletions(-) diff --git a/lib/network.js b/lib/network.js index 11c0d5f..1157ba3 100644 --- a/lib/network.js +++ b/lib/network.js @@ -318,30 +318,46 @@ function getDarwinNics() { } -function getNicDHCPstatus(interfaceName) { - const cmd = `nmcli con sh "${interfaceName}" | grep ipv4.method`; - console.log(cmd); +function getInterfaceConnectionName(interfaceName) { + const cmd = `nmcli device status | grep ${interfaceName}`; + try { - let dhcpStatus = ""; - const lines = execSync(cmd, util.execOptsWin).toString().split('\n'); - const nsections = splitSectionsNics(lines); - console.log(nsections); - switch (key) { - case "auto": - dhcpStatus = "true"; + const result = execSync(cmd).toString(); + const resultFormat = result.replace(/\s+/g,' ').trim(); + const connectionNameLines = resultFormat.split(" ").slice(3); + const connectionName = connectionNameLines.join(' '); + return connectionName != '--' ? connectionName : ''; + } catch (e) { + return ''; + } +} + +function getDHCPstatus(connectionName) { + const cmd = `nmcli connection show "${connectionName}" \| grep ipv4.method;`; + try { + console.log(1); + const result = execSync(cmd).toString(); + console.log(2); + const resultFormat = result.replace(/\s+/g,' ').trim(); + + let dhcStatus = resultFormat.split(" ").slice(1).toString(); + switch (dhcStatus) { + case 'auto': + dhcStatus = true; break; default: - dhcpStatus = "false"; + dhcStatus = false; break; } - return dhcpStatus; + return dhcStatus; } catch (e) { - return []; + return 'Unknow'; } } + function testVirtualNic(iface, ifaceName, mac) { const virtualMacs = ['00:00:00:00:00:00', '00:03:FF', '00:05:69', '00:0C:29', '00:0F:4B', '00:0F:4B', '00:13:07', '00:13:BE', '00:15:5d', '00:16:3E', '00:1C:42', '00:21:F6', '00:21:F6', '00:24:0B', '00:24:0B', '00:50:56', '00:A0:B1', '00:E0:C8', '08:00:27', '0A:00:27', '18:92:2C', '16:DF:49', '3C:F3:92', '54:52:00', 'FC:15:97']; if (mac) { @@ -370,8 +386,6 @@ function networkInterfaces(callback) { nics.forEach(nic => { - dhcpStatus = getNicDHCPstatus(nic.iface); - result.push({ iface: nic.iface, ifaceName: nic.iface, @@ -383,7 +397,6 @@ function networkInterfaces(callback) { operstate: nic.operstate, type: nic.type, duplex: nic.duplex, - dhcpStatus: dhcpStatus, mtu: nic.mtu, speed: nic.speed, carrierChanges: 0 @@ -461,11 +474,16 @@ function networkInterfaces(callback) { echo -n "speed: "; cat /sys/class/net/${iface}/speed 2>/dev/null; echo; echo -n "tx_queue_len: "; cat /sys/class/net/${iface}/tx_queue_len 2>/dev/null; echo; echo -n "type: "; cat /sys/class/net/${iface}/type 2>/dev/null; echo; - echo -n "wireless: "; cat /proc/net/wireless 2>/dev/null \| grep ${iface}; echo + echo -n "wireless: "; cat /proc/net/wireless 2>/dev/null \| grep ${iface}; echo; echo -n "wirelessspeed: "; iw dev ${iface} link 2>&1 \| grep bitrate; echo;`; - let lines = []; + + let lines = []; + try { + const connectionName = getInterfaceConnectionName(iface); + dhcp = getDHCPstatus(connectionName); lines = execSync(cmd).toString().split('\n'); + } catch (e) { util.noop(); From bc335781fed770d67eaaa192706d40204454db8f Mon Sep 17 00:00:00 2001 From: ricardopolo Date: Fri, 1 Nov 2019 10:19:48 -0500 Subject: [PATCH 06/37] Do not show error on dhcp status --- lib/network.js | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/lib/network.js b/lib/network.js index e56fb97..13b9b32 100644 --- a/lib/network.js +++ b/lib/network.js @@ -326,25 +326,27 @@ function getInterfaceConnectionName(interfaceName) { } function getDHCPstatus(connectionName) { - const cmd = `nmcli connection show "${connectionName}" \| grep ipv4.method;`; - try { - console.log(1); - const result = execSync(cmd).toString(); - console.log(2); - const resultFormat = result.replace(/\s+/g,' ').trim(); - - let dhcStatus = resultFormat.split(" ").slice(1).toString(); - switch (dhcStatus) { - case 'auto': - dhcStatus = true; - break; - - default: - dhcStatus = false; - break; + if(connectionName) { + const cmd = `nmcli connection show "${connectionName}" \| grep ipv4.method;`; + try { + const result = execSync(cmd).toString(); + const resultFormat = result.replace(/\s+/g,' ').trim(); + + let dhcStatus = resultFormat.split(" ").slice(1).toString(); + switch (dhcStatus) { + case 'auto': + dhcStatus = true; + break; + + default: + dhcStatus = false; + break; + } + return dhcStatus; + } catch (e) { + return 'Unknow'; } - return dhcStatus; - } catch (e) { + } else { return 'Unknow'; } } From 03eae68972bfe899884a63454820ec2a8b5da921 Mon Sep 17 00:00:00 2001 From: ricardopolo Date: Fri, 1 Nov 2019 10:33:33 -0500 Subject: [PATCH 07/37] get DNS Suffix --- lib/network.js | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/lib/network.js b/lib/network.js index 13b9b32..ae0d5ae 100644 --- a/lib/network.js +++ b/lib/network.js @@ -325,7 +325,7 @@ function getInterfaceConnectionName(interfaceName) { } } -function getDHCPstatus(connectionName) { +function getInterfaceDHCPstatus(connectionName) { if(connectionName) { const cmd = `nmcli connection show "${connectionName}" \| grep ipv4.method;`; try { @@ -351,7 +351,21 @@ function getDHCPstatus(connectionName) { } } - +function getInterfaceDNSsuffix(connectionName) { + if(connectionName) { + const cmd = `nmcli connection show "${connectionName}" \| grep ipv4.dns-search;`; + try { + const result = execSync(cmd).toString(); + const resultFormat = result.replace(/\s+/g,' ').trim(); + const dnsSuffix = resultFormat.split(" ").slice(1).toString(); + return dnsSuffix; + } catch (e) { + return 'Unknow'; + } + } else { + return 'Unknow'; + } +} function testVirtualNic(iface, ifaceName, mac) { const virtualMacs = ['00:00:00:00:00:00', '00:03:FF', '00:05:69', '00:0C:29', '00:0F:4B', '00:0F:4B', '00:13:07', '00:13:BE', '00:15:5d', '00:16:3E', '00:1C:42', '00:21:F6', '00:21:F6', '00:24:0B', '00:24:0B', '00:50:56', '00:A0:B1', '00:E0:C8', '08:00:27', '0A:00:27', '18:92:2C', '16:DF:49', '3C:F3:92', '54:52:00', 'FC:15:97']; @@ -421,6 +435,7 @@ function networkInterfaces(callback) { let carrierChanges = 0; let operstate = 'down'; let dhcp = false; + let dnsSuffix = ''; let type = ''; if (ifaces.hasOwnProperty(dev)) { @@ -475,7 +490,8 @@ function networkInterfaces(callback) { try { const connectionName = getInterfaceConnectionName(iface); - dhcp = getDHCPstatus(connectionName); + dhcp = getInterfaceDHCPstatus(connectionName); + dnsSuffix = getInterfaceDNSsuffix(connectionName); lines = execSync(cmd).toString().split('\n'); @@ -527,6 +543,7 @@ function networkInterfaces(callback) { mtu, speed, dhcp, + dnsSuffix, carrierChanges, }); } From 18b6e8b87d1df55acbefdfcb21183fa6f47c30c6 Mon Sep 17 00:00:00 2001 From: VP-002 U <> Date: Fri, 1 Nov 2019 10:45:05 -0500 Subject: [PATCH 08/37] Get DNS Suffix in linux --- lib/network.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/network.js b/lib/network.js index ae0d5ae..8262242 100644 --- a/lib/network.js +++ b/lib/network.js @@ -311,7 +311,7 @@ function getDarwinNics() { } -function getInterfaceConnectionName(interfaceName) { +function getLinuxIfaceConnectionName(interfaceName) { const cmd = `nmcli device status | grep ${interfaceName}`; try { @@ -325,7 +325,7 @@ function getInterfaceConnectionName(interfaceName) { } } -function getInterfaceDHCPstatus(connectionName) { +function getLinuxIfaceDHCPstatus(connectionName) { if(connectionName) { const cmd = `nmcli connection show "${connectionName}" \| grep ipv4.method;`; try { @@ -351,14 +351,14 @@ function getInterfaceDHCPstatus(connectionName) { } } -function getInterfaceDNSsuffix(connectionName) { +function getLinuxIfaceDNSsuffix(connectionName) { if(connectionName) { const cmd = `nmcli connection show "${connectionName}" \| grep ipv4.dns-search;`; try { const result = execSync(cmd).toString(); const resultFormat = result.replace(/\s+/g,' ').trim(); const dnsSuffix = resultFormat.split(" ").slice(1).toString(); - return dnsSuffix; + return dnsSuffix == '--' ? '': dnsSuffix; } catch (e) { return 'Unknow'; } @@ -489,9 +489,9 @@ function networkInterfaces(callback) { let lines = []; try { - const connectionName = getInterfaceConnectionName(iface); - dhcp = getInterfaceDHCPstatus(connectionName); - dnsSuffix = getInterfaceDNSsuffix(connectionName); + const connectionName = getLinuxIfaceConnectionName(iface); + dhcp = getLinuxIfaceDHCPstatus(connectionName); + dnsSuffix = getLinuxIfaceDNSsuffix(connectionName); lines = execSync(cmd).toString().split('\n'); From f6a95d3c45c876d6fce93f4731c9c1d3a7730c5c Mon Sep 17 00:00:00 2001 From: ricardopolo Date: Fri, 1 Nov 2019 11:29:54 -0500 Subject: [PATCH 09/37] getDNS suffix on windows --- lib/network.js | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/lib/network.js b/lib/network.js index ae0d5ae..fd14f6e 100644 --- a/lib/network.js +++ b/lib/network.js @@ -224,6 +224,72 @@ function getWindowsNics() { } } +function getWindowsDNSsuffixes() { + + let iface = {}; + + let dnsSuffixes = { + primaryDNS: '', + exitCode: 0, + ifaces: [], + }; + + try { + const ipconfig = execSync('ipconfig /all', util.execOptsWin); + const ipconfigArray = ipconfig.output.split('\r\n\r\n'); + ipconfigArray.forEach( (element, index) => { + if(index == 1) { + const longPrimaryDNS = element.split('\r\n').filter((element) => { + return element.toUpperCase().includes('DNS'); + }); + const primaryDNS = longPrimaryDNS[0].substring(longPrimaryDNS[0].lastIndexOf(":")+1); + dnsSuffixes.primaryDNS = primaryDNS.trim(); + if(!dnsSuffixes.primaryDNS) dnsSuffixes.primaryDNS = 'not defined'; + } + if(index > 1) { + if(index % 2 == 0){ + const name = element.substring(element.lastIndexOf(" ")+1).replace(':', ''); + iface.name = name; + }else { + const connectionSpecificDNS = element.split('\r\n').filter((element) => { + return element.toUpperCase().includes('DNS') + }); + const dnsSuffix = connectionSpecificDNS[0].substring(connectionSpecificDNS[0].lastIndexOf(":")+1); + iface.dnsSuffix = dnsSuffix.trim(); + dnsSuffixes.ifaces.push(iface); + iface = {}; + } + } + }); + return dnsSuffixes; + } catch (error) { + console.log('An error occurred trying to bring the DNS suffixes of the network ifaces', error.message); + return { + primaryDNS: '', + exitCode: 0, + ifaces: [], + }; + } + +} + +function getWindowsIfaceDNSsuffix(ifaces, ifacename) { + let dnsSuffix = ''; + try { + const connectionDnsSuffix = ifaces.filter((iface) => { + return ifacename.includes(iface.name); + }).map((iface) => iface.dnsSuffix); + if(connectionDnsSuffix[0]) { + dnsSuffix = connectionDnsSuffix[0]; + } + if(!dnsSuffix) dnsSuffix = 'not defined'; + return dnsSuffix ; + } catch (error) { + console.log('Error getting Connection-specific DNS suffix: ', error.message); + return ''; + } +} + function splitSectionsNics(lines) { const result = []; let section = []; @@ -351,6 +417,8 @@ function getInterfaceDHCPstatus(connectionName) { } } + + function getInterfaceDNSsuffix(connectionName) { if(connectionName) { const cmd = `nmcli connection show "${connectionName}" \| grep ipv4.dns-search;`; @@ -389,6 +457,7 @@ function networkInterfaces(callback) { let ifaces = os.networkInterfaces(); let result = []; let nics = []; + let dnsSuffixes = []; // seperate handling in OSX if (_darwin || _freebsd || _openbsd || _netbsd) { nics = getDarwinNics(); @@ -424,6 +493,7 @@ function networkInterfaces(callback) { _ifaces = ifaces; if (_windows) { nics = getWindowsNics(); + dnsSuffixes = getWindowsDNSsuffixes(); } for (let dev in ifaces) { let ip4 = ''; @@ -514,6 +584,7 @@ function networkInterfaces(callback) { if (iface === 'lo' || iface.startsWith('bond')) { type = 'virtual'; } } if (_windows) { + dnsSuffix = getWindowsIfaceDNSsuffix(dnsSuffixes.ifaces, detail.name); nics.forEach(detail => { if (detail.mac === mac) { ifaceName = detail.name; From 86389999de9dac07493fd15f6bd5b958f8550572 Mon Sep 17 00:00:00 2001 From: juanescarraga <32574306+juanescarraga@users.noreply.github.com> Date: Fri, 1 Nov 2019 12:13:48 -0500 Subject: [PATCH 10/37] fix some fool erros --- lib/network.js | 15 +++++++++------ test.js | 8 ++++++++ 2 files changed, 17 insertions(+), 6 deletions(-) create mode 100644 test.js diff --git a/lib/network.js b/lib/network.js index 4bf4b43..494517e 100644 --- a/lib/network.js +++ b/lib/network.js @@ -233,11 +233,13 @@ function getWindowsDNSsuffixes() { exitCode: 0, ifaces: [], }; - + try { const ipconfig = execSync('ipconfig /all', util.execOptsWin); - const ipconfigArray = ipconfig.output.split('\r\n\r\n'); + const ipconfigArray = ipconfig.split('\r\n\r\n'); + ipconfigArray.forEach( (element, index) => { + if(index == 1) { const longPrimaryDNS = element.split('\r\n').filter((element) => { return element.toUpperCase().includes('DNS'); @@ -261,9 +263,10 @@ function getWindowsDNSsuffixes() { } } }); + return dnsSuffixes; } catch (error) { - console.log('An error occurred trying to bring the DNS suffixes of the network ifaces', error.message); + console.log('An error occurred trying to bring the Connection-specific DNS suffix', error.message); return { primaryDNS: '', exitCode: 0, @@ -282,11 +285,11 @@ function getWindowsIfaceDNSsuffix(ifaces, ifacename) { if(connectionDnsSuffix[0]) { dnsSuffix = connectionDnsSuffix[0]; } - if(!dnsSuffix) dnsSuffix = 'not defined'; + if(!dnsSuffix) dnsSuffix = ''; return dnsSuffix ; } catch (error) { console.log('Error getting Connection-specific DNS suffix: ', error.message); - return ''; + return 'Unknow'; } } @@ -582,7 +585,7 @@ function networkInterfaces(callback) { if (iface === 'lo' || iface.startsWith('bond')) { type = 'virtual'; } } if (_windows) { - dnsSuffix = getWindowsIfaceDNSsuffix(dnsSuffixes.ifaces, detail.name); + dnsSuffix = getWindowsIfaceDNSsuffix(dnsSuffixes.ifaces, dev); nics.forEach(detail => { if (detail.mac === mac) { ifaceName = detail.name; diff --git a/test.js b/test.js new file mode 100644 index 0000000..01d7c0b --- /dev/null +++ b/test.js @@ -0,0 +1,8 @@ +const si = require('./lib/network'); + +async function test(){ + const result = await si.networkInterfaces(); + console.log(result); +} + +test(); \ No newline at end of file From bd7e69be9bd2577f4c424aa452a2b35dd1a65876 Mon Sep 17 00:00:00 2001 From: VP-002 U <> Date: Tue, 5 Nov 2019 14:04:37 -0500 Subject: [PATCH 11/37] Get 802.1x authentication method --- lib/network.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/network.js b/lib/network.js index 494517e..dcd330f 100644 --- a/lib/network.js +++ b/lib/network.js @@ -436,6 +436,22 @@ function getLinuxIfaceDNSsuffix(connectionName) { } } +function getLinuxIfaceAuthProtocol(connectionName) { + if(connectionName) { + const cmd = `nmcli connection show "${connectionName}" \| grep 802-1x.eap;`; + try { + const result = execSync(cmd).toString(); + const resultFormat = result.replace(/\s+/g,' ').trim(); + const authenticationProtocol = resultFormat.split(" ").slice(1).toString(); + return authenticationProtocol == '--' ? '': authenticationProtocol; + } catch (e) { + return 'Not configured'; + } + } else { + return 'Not configured'; + } +} + function testVirtualNic(iface, ifaceName, mac) { const virtualMacs = ['00:00:00:00:00:00', '00:03:FF', '00:05:69', '00:0C:29', '00:0F:4B', '00:0F:4B', '00:13:07', '00:13:BE', '00:15:5d', '00:16:3E', '00:1C:42', '00:21:F6', '00:21:F6', '00:24:0B', '00:24:0B', '00:50:56', '00:A0:B1', '00:E0:C8', '08:00:27', '0A:00:27', '18:92:2C', '16:DF:49', '3C:F3:92', '54:52:00', 'FC:15:97']; if (mac) { @@ -507,6 +523,7 @@ function networkInterfaces(callback) { let operstate = 'down'; let dhcp = false; let dnsSuffix = ''; + let authMethod = ''; let type = ''; if (ifaces.hasOwnProperty(dev)) { @@ -563,6 +580,7 @@ function networkInterfaces(callback) { const connectionName = getLinuxIfaceConnectionName(iface); dhcp = getLinuxIfaceDHCPstatus(connectionName); dnsSuffix = getLinuxIfaceDNSsuffix(connectionName); + authMethod = getLinuxIfaceAuthProtocol(connectionName); lines = execSync(cmd).toString().split('\n'); @@ -585,6 +603,7 @@ function networkInterfaces(callback) { if (iface === 'lo' || iface.startsWith('bond')) { type = 'virtual'; } } if (_windows) { + authMethod = 'Unknow'; dnsSuffix = getWindowsIfaceDNSsuffix(dnsSuffixes.ifaces, dev); nics.forEach(detail => { if (detail.mac === mac) { @@ -616,6 +635,7 @@ function networkInterfaces(callback) { speed, dhcp, dnsSuffix, + authMethod, carrierChanges, }); } From 99fcedf0eeba18e3a1357ba26afc8f18602c5011 Mon Sep 17 00:00:00 2001 From: VP-002 U <> Date: Tue, 5 Nov 2019 14:17:45 -0500 Subject: [PATCH 12/37] get Authentication protocol - Linux --- lib/network.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/network.js b/lib/network.js index dcd330f..5a632b9 100644 --- a/lib/network.js +++ b/lib/network.js @@ -523,7 +523,7 @@ function networkInterfaces(callback) { let operstate = 'down'; let dhcp = false; let dnsSuffix = ''; - let authMethod = ''; + let authProtocol = ''; let type = ''; if (ifaces.hasOwnProperty(dev)) { @@ -580,7 +580,7 @@ function networkInterfaces(callback) { const connectionName = getLinuxIfaceConnectionName(iface); dhcp = getLinuxIfaceDHCPstatus(connectionName); dnsSuffix = getLinuxIfaceDNSsuffix(connectionName); - authMethod = getLinuxIfaceAuthProtocol(connectionName); + authProtocol = getLinuxIfaceAuthProtocol(connectionName); lines = execSync(cmd).toString().split('\n'); @@ -603,7 +603,7 @@ function networkInterfaces(callback) { if (iface === 'lo' || iface.startsWith('bond')) { type = 'virtual'; } } if (_windows) { - authMethod = 'Unknow'; + authProtocol = 'Unknow'; dnsSuffix = getWindowsIfaceDNSsuffix(dnsSuffixes.ifaces, dev); nics.forEach(detail => { if (detail.mac === mac) { @@ -635,7 +635,7 @@ function networkInterfaces(callback) { speed, dhcp, dnsSuffix, - authMethod, + authProtocol, carrierChanges, }); } From a4c27734ed27b66dea1fd1c79bacdd045235d200 Mon Sep 17 00:00:00 2001 From: ricardopolo Date: Tue, 5 Nov 2019 14:32:33 -0500 Subject: [PATCH 13/37] Fix grammar error --- lib/network.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/network.js b/lib/network.js index 5a632b9..3b2a4d6 100644 --- a/lib/network.js +++ b/lib/network.js @@ -289,7 +289,7 @@ function getWindowsIfaceDNSsuffix(ifaces, ifacename) { return dnsSuffix ; } catch (error) { console.log('Error getting Connection-specific DNS suffix: ', error.message); - return 'Unknow'; + return 'Unknown'; } } @@ -413,10 +413,10 @@ function getLinuxIfaceDHCPstatus(connectionName) { } return dhcStatus; } catch (e) { - return 'Unknow'; + return 'Unknown'; } } else { - return 'Unknow'; + return 'Unknown'; } } @@ -429,10 +429,10 @@ function getLinuxIfaceDNSsuffix(connectionName) { const dnsSuffix = resultFormat.split(" ").slice(1).toString(); return dnsSuffix == '--' ? '': dnsSuffix; } catch (e) { - return 'Unknow'; + return 'Unknown'; } } else { - return 'Unknow'; + return 'Unknown'; } } @@ -603,7 +603,7 @@ function networkInterfaces(callback) { if (iface === 'lo' || iface.startsWith('bond')) { type = 'virtual'; } } if (_windows) { - authProtocol = 'Unknow'; + authProtocol = 'Unknown'; dnsSuffix = getWindowsIfaceDNSsuffix(dnsSuffixes.ifaces, dev); nics.forEach(detail => { if (detail.mac === mac) { From 7c3c8b2436cdde54cabb3b28e5f931f312bc0eb2 Mon Sep 17 00:00:00 2001 From: ricardopolo Date: Tue, 12 Nov 2019 11:00:35 -0500 Subject: [PATCH 14/37] Adding 8021x windows function --- lib/network.js | 62 ++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 57 insertions(+), 5 deletions(-) diff --git a/lib/network.js b/lib/network.js index 3b2a4d6..19b5038 100644 --- a/lib/network.js +++ b/lib/network.js @@ -293,6 +293,36 @@ function getWindowsIfaceDNSsuffix(ifaces, ifacename) { } } +function getWindowsIEEE8021x(connectionType) { + let i8021x = { + state: 'Unknown', + protocol: 'Unknown', + }; + if(connectionType == 'wired'){ + try { + const state8021x = execSync('netsh lan show interface', util.execOptsWin); + console.log('state funtion', state8021x); + const stateRsult = state8021x.output.split('\n').pop(); + const currentState = stateRsult.includes('auth'); + i8021x.state = currentState ? 'Enabled' : 'Disabled'; + if (i8021x.state === 'Disabled') { + return i8021x; + } + const protocol8021x = execSync('netsh lan show profiles', util.execOptsWin); + console.log('protocol function', protocol8021x); + protocol8021x.output.split('\r\n').filter((protocolauth) => { + const currentProtocol = protocolauth.includes('EAP'); + if(currentProtocol) i8021x.protocol = protocolauth.split(':').pop(); + }); + return i8021x; + + } catch (error) { + return i8021x; + } + } + return i8021x; +} + function splitSectionsNics(lines) { const result = []; let section = []; @@ -436,13 +466,15 @@ function getLinuxIfaceDNSsuffix(connectionName) { } } -function getLinuxIfaceAuthProtocol(connectionName) { +function getLinuxIfaceAuth8021x(connectionName) { if(connectionName) { const cmd = `nmcli connection show "${connectionName}" \| grep 802-1x.eap;`; try { const result = execSync(cmd).toString(); const resultFormat = result.replace(/\s+/g,' ').trim(); const authenticationProtocol = resultFormat.split(" ").slice(1).toString(); + + return authenticationProtocol == '--' ? '': authenticationProtocol; } catch (e) { return 'Not configured'; @@ -452,6 +484,17 @@ function getLinuxIfaceAuthProtocol(connectionName) { } } +function getLinuxIfaceState8021x(authenticationProtocol) { + if(authenticationProtocol) { + if(authenticationProtocol == 'Not configured'){ + return 'Disabled'; + } + return 'Enabled'; + } else { + return 'Unknown'; + } +} + function testVirtualNic(iface, ifaceName, mac) { const virtualMacs = ['00:00:00:00:00:00', '00:03:FF', '00:05:69', '00:0C:29', '00:0F:4B', '00:0F:4B', '00:13:07', '00:13:BE', '00:15:5d', '00:16:3E', '00:1C:42', '00:21:F6', '00:21:F6', '00:24:0B', '00:24:0B', '00:50:56', '00:A0:B1', '00:E0:C8', '08:00:27', '0A:00:27', '18:92:2C', '16:DF:49', '3C:F3:92', '54:52:00', 'FC:15:97']; if (mac) { @@ -523,7 +566,8 @@ function networkInterfaces(callback) { let operstate = 'down'; let dhcp = false; let dnsSuffix = ''; - let authProtocol = ''; + let auth8021x = ''; + let state8021x = ''; let type = ''; if (ifaces.hasOwnProperty(dev)) { @@ -580,7 +624,8 @@ function networkInterfaces(callback) { const connectionName = getLinuxIfaceConnectionName(iface); dhcp = getLinuxIfaceDHCPstatus(connectionName); dnsSuffix = getLinuxIfaceDNSsuffix(connectionName); - authProtocol = getLinuxIfaceAuthProtocol(connectionName); + auth8021x = getLinuxIfaceAuth8021x(connectionName); + state8021x = getLinuxIfaceState8021x(auth8021x); lines = execSync(cmd).toString().split('\n'); @@ -603,7 +648,8 @@ function networkInterfaces(callback) { if (iface === 'lo' || iface.startsWith('bond')) { type = 'virtual'; } } if (_windows) { - authProtocol = 'Unknown'; + + dnsSuffix = getWindowsIfaceDNSsuffix(dnsSuffixes.ifaces, dev); nics.forEach(detail => { if (detail.mac === mac) { @@ -614,6 +660,11 @@ function networkInterfaces(callback) { type = detail.type; } }); + console.log('type', type); + const IEEE8021x = getWindowsIEEE8021x(type); + console.log('result', IEEE8021x); + auth8021x = IEEE8021x.protocol; + state8021x = IEEE8021x.state; if (dev.toLowerCase().indexOf('wlan') >= 0 || ifaceName.toLowerCase().indexOf('wlan') >= 0 || ifaceName.toLowerCase().indexOf('wireless') >= 0) { type = 'wireless'; } @@ -635,7 +686,8 @@ function networkInterfaces(callback) { speed, dhcp, dnsSuffix, - authProtocol, + auth8021x, + state8021x, carrierChanges, }); } From a12fbc65b455291dcdaac721fa709c01a6a1f6b5 Mon Sep 17 00:00:00 2001 From: juanescarraga <32574306+juanescarraga@users.noreply.github.com> Date: Tue, 12 Nov 2019 11:46:27 -0500 Subject: [PATCH 15/37] Code refactor 8021x on windows --- lib/network.js | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/lib/network.js b/lib/network.js index 19b5038..a7f5600 100644 --- a/lib/network.js +++ b/lib/network.js @@ -300,22 +300,27 @@ function getWindowsIEEE8021x(connectionType) { }; if(connectionType == 'wired'){ try { - const state8021x = execSync('netsh lan show interface', util.execOptsWin); - console.log('state funtion', state8021x); - const stateRsult = state8021x.output.split('\n').pop(); - const currentState = stateRsult.includes('auth'); - i8021x.state = currentState ? 'Enabled' : 'Disabled'; - if (i8021x.state === 'Disabled') { - return i8021x; - } - const protocol8021x = execSync('netsh lan show profiles', util.execOptsWin); - console.log('protocol function', protocol8021x); - protocol8021x.output.split('\r\n').filter((protocolauth) => { - const currentProtocol = protocolauth.includes('EAP'); - if(currentProtocol) i8021x.protocol = protocolauth.split(':').pop(); + + const result = execSync('netsh lan show profiles', util.execOptsWin); + const arrayResult = result.split('\r\n'); + + const state8021x = arrayResult.find((element) => { + return element.includes('802.1x'); }); - return i8021x; - + + if(state8021x.includes('Disabled')){ + i8021x.state = "Disabled"; + i8021x.protocol = "Not Configured"; + return i8021x; + } else { + const protocol8021x = arrayResult.find((element) => { + return element.includes('EAP'); + }); + i8021x.protocol = protocol8021x.split(':').pop(); + i8021x.state = "Enabled"; + return i8021x; + } + } catch (error) { return i8021x; } From 1937eeb3ee39efc70e0ffda5799d75886c6142a9 Mon Sep 17 00:00:00 2001 From: juanescarraga <32574306+juanescarraga@users.noreply.github.com> Date: Tue, 12 Nov 2019 11:49:55 -0500 Subject: [PATCH 16/37] Code refactor --- lib/network.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/network.js b/lib/network.js index a7f5600..e8178a4 100644 --- a/lib/network.js +++ b/lib/network.js @@ -665,9 +665,7 @@ function networkInterfaces(callback) { type = detail.type; } }); - console.log('type', type); const IEEE8021x = getWindowsIEEE8021x(type); - console.log('result', IEEE8021x); auth8021x = IEEE8021x.protocol; state8021x = IEEE8021x.state; if (dev.toLowerCase().indexOf('wlan') >= 0 || ifaceName.toLowerCase().indexOf('wlan') >= 0 || ifaceName.toLowerCase().indexOf('wireless') >= 0) { From a66fffbba7226843c6826935df369d1f714e40f6 Mon Sep 17 00:00:00 2001 From: juanescarraga <32574306+juanescarraga@users.noreply.github.com> Date: Tue, 12 Nov 2019 12:30:08 -0500 Subject: [PATCH 17/37] Code refactor --- lib/network.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/network.js b/lib/network.js index e8178a4..a6d52dc 100644 --- a/lib/network.js +++ b/lib/network.js @@ -293,7 +293,7 @@ function getWindowsIfaceDNSsuffix(ifaces, ifacename) { } } -function getWindowsIEEE8021x(connectionType) { +function getWindowsIEEE8021x(connectionType, iface) { let i8021x = { state: 'Unknown', protocol: 'Unknown', @@ -302,9 +302,16 @@ function getWindowsIEEE8021x(connectionType) { try { const result = execSync('netsh lan show profiles', util.execOptsWin); - const arrayResult = result.split('\r\n'); + const arrayResult = result.split('\r\nProfile on interface'); + + // Get 802.1x information by interface name + const iface8021xInfo = arrayResult.find((element) => { + return element.includes(iface + '\r\n'); + }); - const state8021x = arrayResult.find((element) => { + const arrayIface8021xInfo = iface8021xInfo.split('\r\n') + + const state8021x = arrayIface8021xInfo.find((element) => { return element.includes('802.1x'); }); @@ -313,9 +320,10 @@ function getWindowsIEEE8021x(connectionType) { i8021x.protocol = "Not Configured"; return i8021x; } else { - const protocol8021x = arrayResult.find((element) => { + const protocol8021x = arrayIface8021xInfo.find((element) => { return element.includes('EAP'); }); + i8021x.protocol = protocol8021x.split(':').pop(); i8021x.state = "Enabled"; return i8021x; @@ -665,7 +673,7 @@ function networkInterfaces(callback) { type = detail.type; } }); - const IEEE8021x = getWindowsIEEE8021x(type); + const IEEE8021x = getWindowsIEEE8021x(type, dev); auth8021x = IEEE8021x.protocol; state8021x = IEEE8021x.state; if (dev.toLowerCase().indexOf('wlan') >= 0 || ifaceName.toLowerCase().indexOf('wlan') >= 0 || ifaceName.toLowerCase().indexOf('wireless') >= 0) { From d04af38c442280b65523c984722308ee729632e2 Mon Sep 17 00:00:00 2001 From: ricardopolo Date: Tue, 12 Nov 2019 13:57:04 -0500 Subject: [PATCH 18/37] Testing correct DNS get by name --- lib/network.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/network.js b/lib/network.js index a6d52dc..5b4dfd3 100644 --- a/lib/network.js +++ b/lib/network.js @@ -279,6 +279,8 @@ function getWindowsDNSsuffixes() { function getWindowsIfaceDNSsuffix(ifaces, ifacename) { let dnsSuffix = ''; try { + console.log('aca vamos', ifaces); + console.log(ifacename); const connectionDnsSuffix = ifaces.filter((iface) => { return ifacename.includes(iface.name); }).map((iface) => iface.dnsSuffix); From b97368ba33b839c76c47b854e6bdc47e1001c083 Mon Sep 17 00:00:00 2001 From: juanescarraga <32574306+juanescarraga@users.noreply.github.com> Date: Tue, 12 Nov 2019 14:26:10 -0500 Subject: [PATCH 19/37] Code refactor for DNS suffix --- lib/network.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/network.js b/lib/network.js index 5b4dfd3..c939f30 100644 --- a/lib/network.js +++ b/lib/network.js @@ -278,11 +278,11 @@ function getWindowsDNSsuffixes() { function getWindowsIfaceDNSsuffix(ifaces, ifacename) { let dnsSuffix = ''; + // Adding (.) to ensure ifacename compatibility when duplicated iface-names + const interfaceName = ifacename + '.'; try { - console.log('aca vamos', ifaces); - console.log(ifacename); const connectionDnsSuffix = ifaces.filter((iface) => { - return ifacename.includes(iface.name); + return interfaceName.includes(iface.name + '.'); }).map((iface) => iface.dnsSuffix); if(connectionDnsSuffix[0]) { dnsSuffix = connectionDnsSuffix[0]; From 16e7a2e81db39b7ff8e777b324934e1190b24e47 Mon Sep 17 00:00:00 2001 From: juanescarraga <32574306+juanescarraga@users.noreply.github.com> Date: Tue, 12 Nov 2019 14:31:56 -0500 Subject: [PATCH 20/37] Code refactor --- lib/network.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/network.js b/lib/network.js index c939f30..1323b7e 100644 --- a/lib/network.js +++ b/lib/network.js @@ -332,6 +332,7 @@ function getWindowsIEEE8021x(connectionType, iface) { } } catch (error) { + console.log(error); return i8021x; } } From 746137ef47763c7598b7993db3348786d683459e Mon Sep 17 00:00:00 2001 From: ricardopolo Date: Tue, 12 Nov 2019 14:59:50 -0500 Subject: [PATCH 21/37] Code refactor only get onces Profile information --- lib/network.js | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/lib/network.js b/lib/network.js index 1323b7e..c2b7294 100644 --- a/lib/network.js +++ b/lib/network.js @@ -295,19 +295,25 @@ function getWindowsIfaceDNSsuffix(ifaces, ifacename) { } } -function getWindowsIEEE8021x(connectionType, iface) { +function getWindowsWiredProfilesInformation() { + try { + const result = execSync('netsh lan show profiles', util.execOptsWin); + const profileList = result.split('\r\nProfile on interface'); + return profileList; + } catch (error) { + return []; + } +} + +function getWindowsIEEE8021x(connectionType, iface, ifaces) { let i8021x = { state: 'Unknown', protocol: 'Unknown', }; - if(connectionType == 'wired'){ - try { - - const result = execSync('netsh lan show profiles', util.execOptsWin); - const arrayResult = result.split('\r\nProfile on interface'); - + if(connectionType == 'wired' && ifaces.length > 0){ + try { // Get 802.1x information by interface name - const iface8021xInfo = arrayResult.find((element) => { + const iface8021xInfo = ifaces.find((element) => { return element.includes(iface + '\r\n'); }); @@ -534,6 +540,7 @@ function networkInterfaces(callback) { let result = []; let nics = []; let dnsSuffixes = []; + let nics8021xInfo = []; // seperate handling in OSX if (_darwin || _freebsd || _openbsd || _netbsd) { nics = getDarwinNics(); @@ -568,6 +575,7 @@ function networkInterfaces(callback) { } else { _ifaces = ifaces; if (_windows) { + nics8021xInfo = getWindowsWiredProfilesInformation(); nics = getWindowsNics(); dnsSuffixes = getWindowsDNSsuffixes(); } @@ -676,7 +684,7 @@ function networkInterfaces(callback) { type = detail.type; } }); - const IEEE8021x = getWindowsIEEE8021x(type, dev); + const IEEE8021x = getWindowsIEEE8021x(type, dev, nics8021xInfo); auth8021x = IEEE8021x.protocol; state8021x = IEEE8021x.state; if (dev.toLowerCase().indexOf('wlan') >= 0 || ifaceName.toLowerCase().indexOf('wlan') >= 0 || ifaceName.toLowerCase().indexOf('wireless') >= 0) { From 4fdfa35c8d9b5a0dde32a16be298b94106f586f4 Mon Sep 17 00:00:00 2001 From: ricardopolo Date: Thu, 14 Nov 2019 09:37:10 -0500 Subject: [PATCH 22/37] logs new Wireless funciton 802.1x --- lib/network.js | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/lib/network.js b/lib/network.js index c2b7294..fd178ab 100644 --- a/lib/network.js +++ b/lib/network.js @@ -305,6 +305,20 @@ function getWindowsWiredProfilesInformation() { } } +function getWindowsWirelessIfaceSSID(interfaceName){ + try { + console.log('NOMBRE DE LA INTEFACE:', interfaceName); + const result = execSync(`netsh wlan show interface name="${interfaceName}" | findstr "SSID"`, util.execOptsWin); + const SSID = result.split('\r\n').shift(); + console.log('SSID COMPLETO:', SSID); + const parseSSID = SSID.split(':').pop(); + console.log('SSID FINAL:', parseSSID); + return parseSSID; + } catch (error) { + return 'Unknown'; + } +} + function getWindowsIEEE8021x(connectionType, iface, ifaces) { let i8021x = { state: 'Unknown', @@ -338,10 +352,27 @@ function getWindowsIEEE8021x(connectionType, iface, ifaces) { } } catch (error) { - console.log(error); + console.log('Entro al catch del wired'); return i8021x; } + } else if (connectionType == 'wireless' && ifaces.length > 0){ + try { + const SSID = getWindowsWirelessIfaceSSID(iface); + if(SSID !== 'Unknown') { + let i8021xState = execSync(`netsh wlan show profiles "${SSID}" | findstr "802.1X"`, util.execOptsWin); + i8021x.state = i8021xState.split(':').pop(); + console.log('WIRELESS STATE 802',i8021x.state); + let i8021xProtocol = execSync(`netsh wlan show profiles "${SSID}" | findstr "EAP"`, util.execOptsWin); + i8021x.protocol = i8021xProtocol.split(':').pop(); + console.log('WIRELESS PROTOCOL 802',i8021x.protocol); + } + return i8021x; + } catch (error) { + console.log('Entro al catch del wireless'); + return i8021x; + } } + console.log('Entre al valor por defecto'); return i8021x; } From 72caae8a1c8db86f1bc22cdb8f27a8ebba89dd2d Mon Sep 17 00:00:00 2001 From: ricardopolo Date: Thu, 14 Nov 2019 09:40:52 -0500 Subject: [PATCH 23/37] Handle execption when empty string is return --- lib/network.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/network.js b/lib/network.js index fd178ab..f9d6b40 100644 --- a/lib/network.js +++ b/lib/network.js @@ -360,10 +360,18 @@ function getWindowsIEEE8021x(connectionType, iface, ifaces) { const SSID = getWindowsWirelessIfaceSSID(iface); if(SSID !== 'Unknown') { let i8021xState = execSync(`netsh wlan show profiles "${SSID}" | findstr "802.1X"`, util.execOptsWin); - i8021x.state = i8021xState.split(':').pop(); + if(i8021xState){ + i8021x.state = i8021xState.split(':').pop(); + } else{ + i8021x.state = "Disabled"; + } console.log('WIRELESS STATE 802',i8021x.state); let i8021xProtocol = execSync(`netsh wlan show profiles "${SSID}" | findstr "EAP"`, util.execOptsWin); - i8021x.protocol = i8021xProtocol.split(':').pop(); + if(i8021xProtocol){ + i8021x.protocol = i8021xProtocol.split(':').pop(); + } else{ + i8021x.protocol = "Disabled"; + } console.log('WIRELESS PROTOCOL 802',i8021x.protocol); } return i8021x; From 36d3ba0c67f9c36a5fdd7ee71992ce645f59ce4b Mon Sep 17 00:00:00 2001 From: ricardopolo Date: Thu, 14 Nov 2019 09:45:52 -0500 Subject: [PATCH 24/37] Debuggin wireless funciton 802.1x --- lib/network.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/network.js b/lib/network.js index f9d6b40..0b0f90d 100644 --- a/lib/network.js +++ b/lib/network.js @@ -359,19 +359,21 @@ function getWindowsIEEE8021x(connectionType, iface, ifaces) { try { const SSID = getWindowsWirelessIfaceSSID(iface); if(SSID !== 'Unknown') { + console.log('ETAPA ERROR 1'); let i8021xState = execSync(`netsh wlan show profiles "${SSID}" | findstr "802.1X"`, util.execOptsWin); - if(i8021xState){ - i8021x.state = i8021xState.split(':').pop(); - } else{ - i8021x.state = "Disabled"; - } - console.log('WIRELESS STATE 802',i8021x.state); + console.log('ETAPA ERROR 2'); let i8021xProtocol = execSync(`netsh wlan show profiles "${SSID}" | findstr "EAP"`, util.execOptsWin); - if(i8021xProtocol){ + console.log('ETAPA ERROR 3'); + if(i8021xState && i8021xState){ + console.log('ETAPA ERROR 4'); + i8021x.state = i8021xState.split(':').pop(); + console.log('ETAPA ERROR 5'); i8021x.protocol = i8021xProtocol.split(':').pop(); } else{ - i8021x.protocol = "Disabled"; + i8021x.state = "Disabled"; + i8021x.protocol = "Not configured"; } + console.log('WIRELESS STATE 802',i8021x.state); console.log('WIRELESS PROTOCOL 802',i8021x.protocol); } return i8021x; From 5d5a6ff4397884758d6c31f1d6ec19f66aa11bb9 Mon Sep 17 00:00:00 2001 From: ricardopolo Date: Thu, 14 Nov 2019 10:01:03 -0500 Subject: [PATCH 25/37] Code refactor --- lib/network.js | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/lib/network.js b/lib/network.js index 0b0f90d..e94f29e 100644 --- a/lib/network.js +++ b/lib/network.js @@ -363,24 +363,25 @@ function getWindowsIEEE8021x(connectionType, iface, ifaces) { let i8021xState = execSync(`netsh wlan show profiles "${SSID}" | findstr "802.1X"`, util.execOptsWin); console.log('ETAPA ERROR 2'); let i8021xProtocol = execSync(`netsh wlan show profiles "${SSID}" | findstr "EAP"`, util.execOptsWin); - console.log('ETAPA ERROR 3'); - if(i8021xState && i8021xState){ - console.log('ETAPA ERROR 4'); - i8021x.state = i8021xState.split(':').pop(); - console.log('ETAPA ERROR 5'); - i8021x.protocol = i8021xProtocol.split(':').pop(); - } else{ - i8021x.state = "Disabled"; - i8021x.protocol = "Not configured"; - } - console.log('WIRELESS STATE 802',i8021x.state); - console.log('WIRELESS PROTOCOL 802',i8021x.protocol); + console.log('ETAPA ERROR 3'); } - return i8021x; + } catch (error) { console.log('Entro al catch del wireless'); + i8021x.state = "Disabled"; + i8021x.protocol = "Not configured"; return i8021x; } + + if (i8021xState.includes(':') && i8021xState.includes(':')) { + console.log('ETAPA ERROR 4'); + i8021x.state = i8021xState.split(':').pop(); + console.log('ETAPA ERROR 5'); + i8021x.protocol = i8021xProtocol.split(':').pop(); + } + console.log('WIRELESS STATE 802',i8021x.state); + console.log('WIRELESS PROTOCOL 802',i8021x.protocol); + return i8021x; } console.log('Entre al valor por defecto'); return i8021x; From 7e267aa9af849be8878901c8cc23cb595b50e2c0 Mon Sep 17 00:00:00 2001 From: ricardopolo Date: Thu, 14 Nov 2019 10:03:34 -0500 Subject: [PATCH 26/37] Fix fool error --- lib/network.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/network.js b/lib/network.js index e94f29e..400efdc 100644 --- a/lib/network.js +++ b/lib/network.js @@ -373,7 +373,7 @@ function getWindowsIEEE8021x(connectionType, iface, ifaces) { return i8021x; } - if (i8021xState.includes(':') && i8021xState.includes(':')) { + if (i8021xState.includes(':') && i8021xProtocol.includes(':')) { console.log('ETAPA ERROR 4'); i8021x.state = i8021xState.split(':').pop(); console.log('ETAPA ERROR 5'); From acbcb0c505d9fa53985641c861d283b4751f0306 Mon Sep 17 00:00:00 2001 From: ricardopolo Date: Thu, 14 Nov 2019 10:49:39 -0500 Subject: [PATCH 27/37] code refactor --- lib/network.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/network.js b/lib/network.js index 400efdc..5c2d33d 100644 --- a/lib/network.js +++ b/lib/network.js @@ -324,6 +324,8 @@ function getWindowsIEEE8021x(connectionType, iface, ifaces) { state: 'Unknown', protocol: 'Unknown', }; + let i8021xState = ''; + let i8021xProtocol = ''; if(connectionType == 'wired' && ifaces.length > 0){ try { // Get 802.1x information by interface name @@ -355,14 +357,15 @@ function getWindowsIEEE8021x(connectionType, iface, ifaces) { console.log('Entro al catch del wired'); return i8021x; } - } else if (connectionType == 'wireless' && ifaces.length > 0){ + } else if (connectionType == 'wireless'){ try { - const SSID = getWindowsWirelessIfaceSSID(iface); + // const SSID = getWindowsWirelessIfaceSSID(iface); + const SSID = '1'; if(SSID !== 'Unknown') { console.log('ETAPA ERROR 1'); - let i8021xState = execSync(`netsh wlan show profiles "${SSID}" | findstr "802.1X"`, util.execOptsWin); + i8021xState = execSync(`netsh wlan show profiles "${SSID}" | findstr "802.1X"`, util.execOptsWin); console.log('ETAPA ERROR 2'); - let i8021xProtocol = execSync(`netsh wlan show profiles "${SSID}" | findstr "EAP"`, util.execOptsWin); + i8021xProtocol = execSync(`netsh wlan show profiles "${SSID}" | findstr "EAP"`, util.execOptsWin); console.log('ETAPA ERROR 3'); } From 30396686216b451297eacca896c6d9ce25d3be3c Mon Sep 17 00:00:00 2001 From: ricardopolo Date: Thu, 14 Nov 2019 10:55:23 -0500 Subject: [PATCH 28/37] Do not show console on systeminformation --- lib/network.js | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/lib/network.js b/lib/network.js index 5c2d33d..70874fa 100644 --- a/lib/network.js +++ b/lib/network.js @@ -307,12 +307,9 @@ function getWindowsWiredProfilesInformation() { function getWindowsWirelessIfaceSSID(interfaceName){ try { - console.log('NOMBRE DE LA INTEFACE:', interfaceName); const result = execSync(`netsh wlan show interface name="${interfaceName}" | findstr "SSID"`, util.execOptsWin); const SSID = result.split('\r\n').shift(); - console.log('SSID COMPLETO:', SSID); const parseSSID = SSID.split(':').pop(); - console.log('SSID FINAL:', parseSSID); return parseSSID; } catch (error) { return 'Unknown'; @@ -354,7 +351,7 @@ function getWindowsIEEE8021x(connectionType, iface, ifaces) { } } catch (error) { - console.log('Entro al catch del wired'); + // console.log('Entro al catch del wired'); return i8021x; } } else if (connectionType == 'wireless'){ @@ -362,31 +359,24 @@ function getWindowsIEEE8021x(connectionType, iface, ifaces) { // const SSID = getWindowsWirelessIfaceSSID(iface); const SSID = '1'; if(SSID !== 'Unknown') { - console.log('ETAPA ERROR 1'); i8021xState = execSync(`netsh wlan show profiles "${SSID}" | findstr "802.1X"`, util.execOptsWin); - console.log('ETAPA ERROR 2'); i8021xProtocol = execSync(`netsh wlan show profiles "${SSID}" | findstr "EAP"`, util.execOptsWin); - console.log('ETAPA ERROR 3'); } } catch (error) { - console.log('Entro al catch del wireless'); + // console.log('Entro al catch del wireless'); i8021x.state = "Disabled"; i8021x.protocol = "Not configured"; return i8021x; } if (i8021xState.includes(':') && i8021xProtocol.includes(':')) { - console.log('ETAPA ERROR 4'); i8021x.state = i8021xState.split(':').pop(); - console.log('ETAPA ERROR 5'); i8021x.protocol = i8021xProtocol.split(':').pop(); } - console.log('WIRELESS STATE 802',i8021x.state); - console.log('WIRELESS PROTOCOL 802',i8021x.protocol); return i8021x; } - console.log('Entre al valor por defecto'); + // console.log('Entre al valor por defecto'); return i8021x; } From 3787fa49ecf34721a8b5b34625b8ec2bc7ab88a0 Mon Sep 17 00:00:00 2001 From: "juan.escarraga@tulpep.com" Date: Thu, 14 Nov 2019 11:36:36 -0500 Subject: [PATCH 29/37] Update network.js --- lib/network.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/network.js b/lib/network.js index 70874fa..09d278e 100644 --- a/lib/network.js +++ b/lib/network.js @@ -356,8 +356,8 @@ function getWindowsIEEE8021x(connectionType, iface, ifaces) { } } else if (connectionType == 'wireless'){ try { - // const SSID = getWindowsWirelessIfaceSSID(iface); - const SSID = '1'; + const SSID = getWindowsWirelessIfaceSSID(iface); + // const SSID = '1'; if(SSID !== 'Unknown') { i8021xState = execSync(`netsh wlan show profiles "${SSID}" | findstr "802.1X"`, util.execOptsWin); i8021xProtocol = execSync(`netsh wlan show profiles "${SSID}" | findstr "EAP"`, util.execOptsWin); From 94efdd4168bb5a5dc3444ad7a057e2d1e305d944 Mon Sep 17 00:00:00 2001 From: ricardopolo Date: Thu, 14 Nov 2019 16:53:53 -0500 Subject: [PATCH 30/37] update errors on systeminformation --- lib/network.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/network.js b/lib/network.js index 70874fa..c7a7e99 100644 --- a/lib/network.js +++ b/lib/network.js @@ -719,12 +719,13 @@ function networkInterfaces(callback) { type = detail.type; } }); + + if (dev.toLowerCase().indexOf('wlan') >= 0 || ifaceName.toLowerCase().indexOf('wlan') >= 0 || ifaceName.toLowerCase().indexOf('wireless') >= 0 || ifaceName.toLowerCase().indexOf('wi-fi') >= 0) { + type = 'wireless'; + } const IEEE8021x = getWindowsIEEE8021x(type, dev, nics8021xInfo); auth8021x = IEEE8021x.protocol; state8021x = IEEE8021x.state; - if (dev.toLowerCase().indexOf('wlan') >= 0 || ifaceName.toLowerCase().indexOf('wlan') >= 0 || ifaceName.toLowerCase().indexOf('wireless') >= 0) { - type = 'wireless'; - } } let internal = (ifaces[dev] && ifaces[dev][0]) ? ifaces[dev][0].internal : null; const virtual = internal ? false : testVirtualNic(dev, ifaceName, mac); From e6603ab742dc47a195628b39c77a6649cab520f8 Mon Sep 17 00:00:00 2001 From: VP-002 U <> Date: Fri, 15 Nov 2019 12:06:14 -0500 Subject: [PATCH 31/37] Standar logs messages --- lib/network.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/lib/network.js b/lib/network.js index 407a92d..7dff912 100644 --- a/lib/network.js +++ b/lib/network.js @@ -246,7 +246,7 @@ function getWindowsDNSsuffixes() { }); const primaryDNS = longPrimaryDNS[0].substring(longPrimaryDNS[0].lastIndexOf(":")+1); dnsSuffixes.primaryDNS = primaryDNS.trim(); - if(!dnsSuffixes.primaryDNS) dnsSuffixes.primaryDNS = 'not defined'; + if(!dnsSuffixes.primaryDNS) dnsSuffixes.primaryDNS = 'Not defined'; } if(index > 1) { if(index % 2 == 0){ @@ -338,7 +338,7 @@ function getWindowsIEEE8021x(connectionType, iface, ifaces) { if(state8021x.includes('Disabled')){ i8021x.state = "Disabled"; - i8021x.protocol = "Not Configured"; + i8021x.protocol = "Not defined"; return i8021x; } else { const protocol8021x = arrayIface8021xInfo.find((element) => { @@ -366,7 +366,7 @@ function getWindowsIEEE8021x(connectionType, iface, ifaces) { } catch (error) { // console.log('Entro al catch del wireless'); i8021x.state = "Disabled"; - i8021x.protocol = "Not configured"; + i8021x.protocol = "Not defined"; return i8021x; } @@ -514,7 +514,7 @@ function getLinuxIfaceDNSsuffix(connectionName) { const result = execSync(cmd).toString(); const resultFormat = result.replace(/\s+/g,' ').trim(); const dnsSuffix = resultFormat.split(" ").slice(1).toString(); - return dnsSuffix == '--' ? '': dnsSuffix; + return dnsSuffix == '--' ? 'Not defined': dnsSuffix; } catch (e) { return 'Unknown'; } @@ -534,16 +534,16 @@ function getLinuxIfaceAuth8021x(connectionName) { return authenticationProtocol == '--' ? '': authenticationProtocol; } catch (e) { - return 'Not configured'; + return 'Not defined'; } } else { - return 'Not configured'; + return 'Not defined'; } } function getLinuxIfaceState8021x(authenticationProtocol) { if(authenticationProtocol) { - if(authenticationProtocol == 'Not configured'){ + if(authenticationProtocol == 'Not defined'){ return 'Disabled'; } return 'Enabled'; @@ -678,7 +678,6 @@ function networkInterfaces(callback) { echo -n "wirelessspeed: "; iw dev ${iface} link 2>&1 \| grep bitrate; echo;`; let lines = []; - try { const connectionName = getLinuxIfaceConnectionName(iface); dhcp = getLinuxIfaceDHCPstatus(connectionName); From bbd11de7b06a9311e2eadb18ca2409dc9a28f7a9 Mon Sep 17 00:00:00 2001 From: ricardopolo Date: Fri, 15 Nov 2019 15:54:00 -0500 Subject: [PATCH 32/37] Code refactor --- lib/network.js | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/lib/network.js b/lib/network.js index 7dff912..9ddca21 100644 --- a/lib/network.js +++ b/lib/network.js @@ -214,7 +214,7 @@ function parseLinesWindowsNics(sections, nconfigsections) { function getWindowsNics() { const cmd = util.getWmic() + ' nic get MACAddress, name, NetEnabled, Speed, NetConnectionStatus, AdapterTypeId /value'; - const cmdnicconfig = util.getWmic() + ' nicconfig get dhcpEnabled, DNSDomainSuffixSearchOrder /value'; + const cmdnicconfig = util.getWmic() + ' nicconfig get dhcpEnabled /value'; try { const nsections = execSync(cmd, util.execOptsWin).split(/\n\s*\n/); const nconfigsections = execSync(cmdnicconfig, util.execOptsWin).split(/\n\s*\n/); @@ -315,7 +315,6 @@ function getWindowsWirelessIfaceSSID(interfaceName){ return 'Unknown'; } } - function getWindowsIEEE8021x(connectionType, iface, ifaces) { let i8021x = { state: 'Unknown', @@ -340,31 +339,29 @@ function getWindowsIEEE8021x(connectionType, iface, ifaces) { i8021x.state = "Disabled"; i8021x.protocol = "Not defined"; return i8021x; - } else { + } else if (state8021x.includes('Enabled')) { const protocol8021x = arrayIface8021xInfo.find((element) => { return element.includes('EAP'); }); i8021x.protocol = protocol8021x.split(':').pop(); i8021x.state = "Enabled"; - return i8021x; } } catch (error) { - // console.log('Entro al catch del wired'); + // console.log('Error getting wired information:', error); return i8021x; } } else if (connectionType == 'wireless'){ try { const SSID = getWindowsWirelessIfaceSSID(iface); - // const SSID = '1'; if(SSID !== 'Unknown') { i8021xState = execSync(`netsh wlan show profiles "${SSID}" | findstr "802.1X"`, util.execOptsWin); i8021xProtocol = execSync(`netsh wlan show profiles "${SSID}" | findstr "EAP"`, util.execOptsWin); } } catch (error) { - // console.log('Entro al catch del wireless'); + // console.log('Error getting wireless information:', error); i8021x.state = "Disabled"; i8021x.protocol = "Not defined"; return i8021x; @@ -374,9 +371,8 @@ function getWindowsIEEE8021x(connectionType, iface, ifaces) { i8021x.state = i8021xState.split(':').pop(); i8021x.protocol = i8021xProtocol.split(':').pop(); } - return i8021x; } - // console.log('Entre al valor por defecto'); + return i8021x; } From 3e275d2d3aa583f5ad4a433124e6b0859ddf640e Mon Sep 17 00:00:00 2001 From: ricardopolo Date: Mon, 18 Nov 2019 10:12:40 -0500 Subject: [PATCH 33/37] Code refactor on systeminformation --- lib/network.js | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/lib/network.js b/lib/network.js index 9ddca21..0abd27e 100644 --- a/lib/network.js +++ b/lib/network.js @@ -301,6 +301,9 @@ function getWindowsWiredProfilesInformation() { const profileList = result.split('\r\nProfile on interface'); return profileList; } catch (error) { + if(error.status === 1 && error.stdout.includes('AutoConfig')){ + return 'Disabled'; + } return []; } } @@ -320,8 +323,13 @@ function getWindowsIEEE8021x(connectionType, iface, ifaces) { state: 'Unknown', protocol: 'Unknown', }; - let i8021xState = ''; - let i8021xProtocol = ''; + + if(ifaces === 'Disabled'){ + i8021x.state = "Disabled"; + i8021x.protocol = "Not defined"; + return i8021x; + } + if(connectionType == 'wired' && ifaces.length > 0){ try { // Get 802.1x information by interface name @@ -338,7 +346,7 @@ function getWindowsIEEE8021x(connectionType, iface, ifaces) { if(state8021x.includes('Disabled')){ i8021x.state = "Disabled"; i8021x.protocol = "Not defined"; - return i8021x; + } else if (state8021x.includes('Enabled')) { const protocol8021x = arrayIface8021xInfo.find((element) => { return element.includes('EAP'); @@ -353,6 +361,10 @@ function getWindowsIEEE8021x(connectionType, iface, ifaces) { return i8021x; } } else if (connectionType == 'wireless'){ + + let i8021xState = ''; + let i8021xProtocol = ''; + try { const SSID = getWindowsWirelessIfaceSSID(iface); if(SSID !== 'Unknown') { @@ -360,17 +372,18 @@ function getWindowsIEEE8021x(connectionType, iface, ifaces) { i8021xProtocol = execSync(`netsh wlan show profiles "${SSID}" | findstr "EAP"`, util.execOptsWin); } + if (i8021xState.includes(':') && i8021xProtocol.includes(':')) { + i8021x.state = i8021xState.split(':').pop(); + i8021x.protocol = i8021xProtocol.split(':').pop(); + } } catch (error) { // console.log('Error getting wireless information:', error); + if(error.status === 1 && error.stdout.includes('AutoConfig')){ i8021x.state = "Disabled"; i8021x.protocol = "Not defined"; + } return i8021x; } - - if (i8021xState.includes(':') && i8021xProtocol.includes(':')) { - i8021x.state = i8021xState.split(':').pop(); - i8021x.protocol = i8021xProtocol.split(':').pop(); - } } return i8021x; @@ -718,6 +731,7 @@ function networkInterfaces(callback) { if (dev.toLowerCase().indexOf('wlan') >= 0 || ifaceName.toLowerCase().indexOf('wlan') >= 0 || ifaceName.toLowerCase().indexOf('wireless') >= 0 || ifaceName.toLowerCase().indexOf('wi-fi') >= 0) { type = 'wireless'; } + const IEEE8021x = getWindowsIEEE8021x(type, dev, nics8021xInfo); auth8021x = IEEE8021x.protocol; state8021x = IEEE8021x.state; From 7a4f7b6ff8d01578f8f9ec1f0ee78eff85e17b82 Mon Sep 17 00:00:00 2001 From: ricardopolo Date: Wed, 20 Nov 2019 08:48:11 -0500 Subject: [PATCH 34/37] New version --- lib/network.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/network.js b/lib/network.js index 0abd27e..94f843f 100644 --- a/lib/network.js +++ b/lib/network.js @@ -346,7 +346,7 @@ function getWindowsIEEE8021x(connectionType, iface, ifaces) { if(state8021x.includes('Disabled')){ i8021x.state = "Disabled"; i8021x.protocol = "Not defined"; - + } else if (state8021x.includes('Enabled')) { const protocol8021x = arrayIface8021xInfo.find((element) => { return element.includes('EAP'); @@ -365,6 +365,8 @@ function getWindowsIEEE8021x(connectionType, iface, ifaces) { let i8021xState = ''; let i8021xProtocol = ''; + + try { const SSID = getWindowsWirelessIfaceSSID(iface); if(SSID !== 'Unknown') { From 1d43523d0f70bfd649b8890f59b49e84d52d24c4 Mon Sep 17 00:00:00 2001 From: ricardopolo Date: Thu, 28 Nov 2019 10:35:08 -0500 Subject: [PATCH 35/37] Delete test file --- test.js | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 test.js diff --git a/test.js b/test.js deleted file mode 100644 index 01d7c0b..0000000 --- a/test.js +++ /dev/null @@ -1,8 +0,0 @@ -const si = require('./lib/network'); - -async function test(){ - const result = await si.networkInterfaces(); - console.log(result); -} - -test(); \ No newline at end of file From 1c75329d8051348f38ce5ccdcf6c5bf0a3659649 Mon Sep 17 00:00:00 2001 From: ricardopolo Date: Thu, 28 Nov 2019 11:18:44 -0500 Subject: [PATCH 36/37] Adding pending wireless validation --- lib/network.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/network.js b/lib/network.js index 192c6e9..4d45b34 100644 --- a/lib/network.js +++ b/lib/network.js @@ -730,7 +730,7 @@ function networkInterfaces(callback) { } }); - if (dev.toLowerCase().indexOf('wlan') >= 0 || ifaceName.toLowerCase().indexOf('wlan') >= 0 || ifaceName.toLowerCase().indexOf('wireless') >= 0 || ifaceName.toLowerCase().indexOf('wi-fi') >= 0) { + if (dev.toLowerCase().indexOf('wlan') >= 0 || ifaceName.toLowerCase().indexOf('wlan') >= 0 || ifaceName.toLowerCase().indexOf('wireless') >= 0 || ifaceName.toLowerCase().indexOf('wi-fi') >= 0 || ifaceName.toLowerCase().indexOf('wifi') >= 0) { type = 'wireless'; } From 8c2777f3e433bff3fa74dd25ce3d0593709c9203 Mon Sep 17 00:00:00 2001 From: Koraniar 2 Date: Mon, 16 Dec 2019 09:52:18 -0500 Subject: [PATCH 37/37] Detecting Wireless information on in Virtual Machine --- lib/network.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/network.js b/lib/network.js index 4d45b34..a925112 100644 --- a/lib/network.js +++ b/lib/network.js @@ -730,7 +730,7 @@ function networkInterfaces(callback) { } }); - if (dev.toLowerCase().indexOf('wlan') >= 0 || ifaceName.toLowerCase().indexOf('wlan') >= 0 || ifaceName.toLowerCase().indexOf('wireless') >= 0 || ifaceName.toLowerCase().indexOf('wi-fi') >= 0 || ifaceName.toLowerCase().indexOf('wifi') >= 0) { + if (dev.toLowerCase().indexOf('wlan') >= 0 || ifaceName.toLowerCase().indexOf('wlan') >= 0|| ifaceName.toLowerCase().indexOf('802.11n') >= 0 || ifaceName.toLowerCase().indexOf('wireless') >= 0 || ifaceName.toLowerCase().indexOf('wi-fi') >= 0 || ifaceName.toLowerCase().indexOf('wifi') >= 0) { type = 'wireless'; }