Code refactor only get onces Profile information
This commit is contained in:
parent
16e7a2e81d
commit
746137ef47
@ -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 = {
|
let i8021x = {
|
||||||
state: 'Unknown',
|
state: 'Unknown',
|
||||||
protocol: 'Unknown',
|
protocol: 'Unknown',
|
||||||
};
|
};
|
||||||
if(connectionType == 'wired'){
|
if(connectionType == 'wired' && ifaces.length > 0){
|
||||||
try {
|
try {
|
||||||
|
|
||||||
const result = execSync('netsh lan show profiles', util.execOptsWin);
|
|
||||||
const arrayResult = result.split('\r\nProfile on interface');
|
|
||||||
|
|
||||||
// Get 802.1x information by interface name
|
// Get 802.1x information by interface name
|
||||||
const iface8021xInfo = arrayResult.find((element) => {
|
const iface8021xInfo = ifaces.find((element) => {
|
||||||
return element.includes(iface + '\r\n');
|
return element.includes(iface + '\r\n');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -534,6 +540,7 @@ function networkInterfaces(callback) {
|
|||||||
let result = [];
|
let result = [];
|
||||||
let nics = [];
|
let nics = [];
|
||||||
let dnsSuffixes = [];
|
let dnsSuffixes = [];
|
||||||
|
let nics8021xInfo = [];
|
||||||
// seperate handling in OSX
|
// seperate handling in OSX
|
||||||
if (_darwin || _freebsd || _openbsd || _netbsd) {
|
if (_darwin || _freebsd || _openbsd || _netbsd) {
|
||||||
nics = getDarwinNics();
|
nics = getDarwinNics();
|
||||||
@ -568,6 +575,7 @@ function networkInterfaces(callback) {
|
|||||||
} else {
|
} else {
|
||||||
_ifaces = ifaces;
|
_ifaces = ifaces;
|
||||||
if (_windows) {
|
if (_windows) {
|
||||||
|
nics8021xInfo = getWindowsWiredProfilesInformation();
|
||||||
nics = getWindowsNics();
|
nics = getWindowsNics();
|
||||||
dnsSuffixes = getWindowsDNSsuffixes();
|
dnsSuffixes = getWindowsDNSsuffixes();
|
||||||
}
|
}
|
||||||
@ -676,7 +684,7 @@ function networkInterfaces(callback) {
|
|||||||
type = detail.type;
|
type = detail.type;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const IEEE8021x = getWindowsIEEE8021x(type, dev);
|
const IEEE8021x = getWindowsIEEE8021x(type, dev, nics8021xInfo);
|
||||||
auth8021x = IEEE8021x.protocol;
|
auth8021x = IEEE8021x.protocol;
|
||||||
state8021x = IEEE8021x.state;
|
state8021x = IEEE8021x.state;
|
||||||
if (dev.toLowerCase().indexOf('wlan') >= 0 || ifaceName.toLowerCase().indexOf('wlan') >= 0 || ifaceName.toLowerCase().indexOf('wireless') >= 0) {
|
if (dev.toLowerCase().indexOf('wlan') >= 0 || ifaceName.toLowerCase().indexOf('wlan') >= 0 || ifaceName.toLowerCase().indexOf('wireless') >= 0) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user