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; }