| 4.23.7 |
2020-04-2& |
diff --git a/docs/index.html b/docs/index.html
index 4a94af0..b75c294 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -168,7 +168,7 @@
systeminformation
- Current Version: 4.23.7
+ Current Version: 4.23.8
diff --git a/lib/network.js b/lib/network.js
index e2f8e1d..fd1bf7e 100644
--- a/lib/network.js
+++ b/lib/network.js
@@ -64,10 +64,10 @@ function getDefaultNetworkInterface() {
try {
if (_windows) {
// https://www.inetdaemon.com/tutorials/internet/ip/routing/default_route.shtml
+ let defaultIp = '';
const cmd = 'netstat -r';
const result = execSync(cmd);
const lines = result.toString().split(os.EOL);
- let defaultIp = '';
lines.forEach(line => {
line = line.replace(/\s+/g, ' ').trim();
if (line.indexOf('0.0.0.0 0.0.0.0') > -1 && !(/[a-zA-Z]/.test(line))) {
@@ -126,46 +126,54 @@ function getMacAddresses() {
pathToIp = '';
}
}
- const cmd = 'export LC_ALL=C; ' + ((pathToIp) ? pathToIp + ' link show up' : '/sbin/ifconfig') + '; unset LC_ALL';
- let res = execSync(cmd);
- const lines = res.toString().split('\n');
- for (let i = 0; i < lines.length; i++) {
- if (lines[i] && lines[i][0] !== ' ') {
- if (pathToIp) {
- let nextline = lines[i + 1].trim().split(' ');
- if (nextline[0] === 'link/ether') {
- iface = lines[i].split(' ')[1];
- iface = iface.slice(0, iface.length - 1);
- mac = nextline[1];
+ try {
+ const cmd = 'export LC_ALL=C; ' + ((pathToIp) ? pathToIp + ' link show up' : '/sbin/ifconfig') + '; unset LC_ALL';
+ let res = execSync(cmd);
+ const lines = res.toString().split('\n');
+ for (let i = 0; i < lines.length; i++) {
+ if (lines[i] && lines[i][0] !== ' ') {
+ if (pathToIp) {
+ let nextline = lines[i + 1].trim().split(' ');
+ if (nextline[0] === 'link/ether') {
+ iface = lines[i].split(' ')[1];
+ iface = iface.slice(0, iface.length - 1);
+ mac = nextline[1];
+ }
+ } else {
+ iface = lines[i].split(' ')[0];
+ mac = lines[i].split('HWaddr ')[1];
}
- } else {
- iface = lines[i].split(' ')[0];
- mac = lines[i].split('HWaddr ')[1];
- }
- if (iface && mac) {
- result[iface] = mac.trim();
- iface = '';
- mac = '';
+ if (iface && mac) {
+ result[iface] = mac.trim();
+ iface = '';
+ mac = '';
+ }
}
}
+ } catch (e) {
+ util.noop();
}
}
if (_darwin) {
- const cmd = '/sbin/ifconfig';
- let res = execSync(cmd);
- const lines = res.toString().split('\n');
- for (let i = 0; i < lines.length; i++) {
- if (lines[i] && lines[i][0] !== '\t' && lines[i].indexOf(':') > 0) {
- iface = lines[i].split(':')[0];
- } else if (lines[i].indexOf('\tether ') === 0) {
- mac = lines[i].split('\tether ')[1];
- if (iface && mac) {
- result[iface] = mac.trim();
- iface = '';
- mac = '';
+ try {
+ const cmd = '/sbin/ifconfig';
+ let res = execSync(cmd);
+ const lines = res.toString().split('\n');
+ for (let i = 0; i < lines.length; i++) {
+ if (lines[i] && lines[i][0] !== '\t' && lines[i].indexOf(':') > 0) {
+ iface = lines[i].split(':')[0];
+ } else if (lines[i].indexOf('\tether ') === 0) {
+ mac = lines[i].split('\tether ')[1];
+ if (iface && mac) {
+ result[iface] = mac.trim();
+ iface = '';
+ mac = '';
+ }
}
}
+ } catch (e) {
+ util.noop();
}
}
return result;
@@ -491,21 +499,25 @@ function getLinuxIfaceConnectionName(interfaceName) {
function checkLinuxDCHPInterfaces(file) {
let result = [];
- let cmd = `cat ${file} 2> /dev/null | grep 'iface\\|source'`;
- const lines = execSync(cmd, { maxBuffer: 1024 * 20000 }).toString().split('\n');
+ try {
+ let cmd = `cat ${file} 2> /dev/null | grep 'iface\\|source'`;
+ const lines = execSync(cmd, { maxBuffer: 1024 * 20000 }).toString().split('\n');
- lines.forEach(line => {
- const parts = line.replace(/\s+/g, ' ').trim().split(' ');
- if (parts.length >= 4) {
- if (line.toLowerCase().indexOf(' inet ') >= 0 && line.toLowerCase().indexOf('dhcp') >= 0) {
- result.push(parts[1]);
+ lines.forEach(line => {
+ const parts = line.replace(/\s+/g, ' ').trim().split(' ');
+ if (parts.length >= 4) {
+ if (line.toLowerCase().indexOf(' inet ') >= 0 && line.toLowerCase().indexOf('dhcp') >= 0) {
+ result.push(parts[1]);
+ }
}
- }
- if (line.toLowerCase().includes('source')) {
- let file = line.split(' ')[1];
- result = result.concat(checkLinuxDCHPInterfaces(file));
- }
- });
+ if (line.toLowerCase().includes('source')) {
+ let file = line.split(' ')[1];
+ result = result.concat(checkLinuxDCHPInterfaces(file));
+ }
+ });
+ } catch (e) {
+ util.noop();
+ }
return result;
}