Code refactor

This commit is contained in:
ricardopolo 2019-11-15 15:54:00 -05:00
parent e6603ab742
commit bbd11de7b0

View File

@ -214,7 +214,7 @@ function parseLinesWindowsNics(sections, nconfigsections) {
function getWindowsNics() { function getWindowsNics() {
const cmd = util.getWmic() + ' nic get MACAddress, name, NetEnabled, Speed, NetConnectionStatus, AdapterTypeId /value'; 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 { try {
const nsections = execSync(cmd, util.execOptsWin).split(/\n\s*\n/); const nsections = execSync(cmd, util.execOptsWin).split(/\n\s*\n/);
const nconfigsections = execSync(cmdnicconfig, 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'; return 'Unknown';
} }
} }
function getWindowsIEEE8021x(connectionType, iface, ifaces) { function getWindowsIEEE8021x(connectionType, iface, ifaces) {
let i8021x = { let i8021x = {
state: 'Unknown', state: 'Unknown',
@ -340,31 +339,29 @@ function getWindowsIEEE8021x(connectionType, iface, ifaces) {
i8021x.state = "Disabled"; i8021x.state = "Disabled";
i8021x.protocol = "Not defined"; i8021x.protocol = "Not defined";
return i8021x; return i8021x;
} else { } else if (state8021x.includes('Enabled')) {
const protocol8021x = arrayIface8021xInfo.find((element) => { const protocol8021x = arrayIface8021xInfo.find((element) => {
return element.includes('EAP'); return element.includes('EAP');
}); });
i8021x.protocol = protocol8021x.split(':').pop(); i8021x.protocol = protocol8021x.split(':').pop();
i8021x.state = "Enabled"; i8021x.state = "Enabled";
return i8021x;
} }
} catch (error) { } catch (error) {
// console.log('Entro al catch del wired'); // console.log('Error getting wired information:', error);
return i8021x; return i8021x;
} }
} else if (connectionType == 'wireless'){ } else if (connectionType == 'wireless'){
try { try {
const SSID = getWindowsWirelessIfaceSSID(iface); const SSID = getWindowsWirelessIfaceSSID(iface);
// const SSID = '1';
if(SSID !== 'Unknown') { if(SSID !== 'Unknown') {
i8021xState = execSync(`netsh wlan show profiles "${SSID}" | findstr "802.1X"`, util.execOptsWin); i8021xState = execSync(`netsh wlan show profiles "${SSID}" | findstr "802.1X"`, util.execOptsWin);
i8021xProtocol = execSync(`netsh wlan show profiles "${SSID}" | findstr "EAP"`, util.execOptsWin); i8021xProtocol = execSync(`netsh wlan show profiles "${SSID}" | findstr "EAP"`, util.execOptsWin);
} }
} catch (error) { } catch (error) {
// console.log('Entro al catch del wireless'); // console.log('Error getting wireless information:', error);
i8021x.state = "Disabled"; i8021x.state = "Disabled";
i8021x.protocol = "Not defined"; i8021x.protocol = "Not defined";
return i8021x; return i8021x;
@ -374,9 +371,8 @@ function getWindowsIEEE8021x(connectionType, iface, ifaces) {
i8021x.state = i8021xState.split(':').pop(); i8021x.state = i8021xState.split(':').pop();
i8021x.protocol = i8021xProtocol.split(':').pop(); i8021x.protocol = i8021xProtocol.split(':').pop();
} }
return i8021x;
} }
// console.log('Entre al valor por defecto');
return i8021x; return i8021x;
} }