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