Code refactor on systeminformation
This commit is contained in:
parent
bbd11de7b0
commit
3e275d2d3a
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user