fix some fool erros

This commit is contained in:
juanescarraga 2019-11-01 12:13:48 -05:00
parent 3ef962a830
commit 86389999de
2 changed files with 17 additions and 6 deletions

View File

@ -233,11 +233,13 @@ function getWindowsDNSsuffixes() {
exitCode: 0,
ifaces: [],
};
try {
const ipconfig = execSync('ipconfig /all', util.execOptsWin);
const ipconfigArray = ipconfig.output.split('\r\n\r\n');
const ipconfigArray = ipconfig.split('\r\n\r\n');
ipconfigArray.forEach( (element, index) => {
if(index == 1) {
const longPrimaryDNS = element.split('\r\n').filter((element) => {
return element.toUpperCase().includes('DNS');
@ -261,9 +263,10 @@ function getWindowsDNSsuffixes() {
}
}
});
return dnsSuffixes;
} catch (error) {
console.log('An error occurred trying to bring the DNS suffixes of the network ifaces', error.message);
console.log('An error occurred trying to bring the Connection-specific DNS suffix', error.message);
return {
primaryDNS: '',
exitCode: 0,
@ -282,11 +285,11 @@ function getWindowsIfaceDNSsuffix(ifaces, ifacename) {
if(connectionDnsSuffix[0]) {
dnsSuffix = connectionDnsSuffix[0];
}
if(!dnsSuffix) dnsSuffix = 'not defined';
if(!dnsSuffix) dnsSuffix = '';
return dnsSuffix ;
} catch (error) {
console.log('Error getting Connection-specific DNS suffix: ', error.message);
return '';
return 'Unknow';
}
}
@ -582,7 +585,7 @@ function networkInterfaces(callback) {
if (iface === 'lo' || iface.startsWith('bond')) { type = 'virtual'; }
}
if (_windows) {
dnsSuffix = getWindowsIfaceDNSsuffix(dnsSuffixes.ifaces, detail.name);
dnsSuffix = getWindowsIfaceDNSsuffix(dnsSuffixes.ifaces, dev);
nics.forEach(detail => {
if (detail.mac === mac) {
ifaceName = detail.name;

8
test.js Normal file
View File

@ -0,0 +1,8 @@
const si = require('./lib/network');
async function test(){
const result = await si.networkInterfaces();
console.log(result);
}
test();