Code refactor 8021x on windows

This commit is contained in:
juanescarraga 2019-11-12 11:46:27 -05:00
parent 7c3c8b2436
commit a12fbc65b4

View File

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