getMacAddresses() fix added try catch

This commit is contained in:
Sebastian Hildebrandt 2020-04-26 18:51:01 +02:00
parent d8fc1520ec
commit 3d61fe987c
4 changed files with 64 additions and 46 deletions

View File

@ -30,6 +30,7 @@ For major (breaking) changes - version 3 and 2 see end of page.
| Version | Date | Comment | | Version | Date | Comment |
| -------------- | -------------- | -------- | | -------------- | -------------- | -------- |
| 4.23.8 | 2020-04-26 | `getMacAddresses()` fix added try catch |
| 4.23.7 | 2020-04-26 | `getCpuCurrentSpeedSync()` workarround fix | | 4.23.7 | 2020-04-26 | `getCpuCurrentSpeedSync()` workarround fix |
| 4.23.6 | 2020-04-25 | `networkGatewayDefault()` bug fix no interfaces | | 4.23.6 | 2020-04-25 | `networkGatewayDefault()` bug fix no interfaces |
| 4.23.5 | 2020-04-20 | updated docs | | 4.23.5 | 2020-04-20 | updated docs |

View File

@ -83,6 +83,11 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr>
<th scope="row">4.23.8</th>
<td>2020-04-2&</td>
<td><span class="code">getMacAddresses()</span> fix added try catch</td>
</tr>
<tr> <tr>
<th scope="row">4.23.7</th> <th scope="row">4.23.7</th>
<td>2020-04-2&</td> <td>2020-04-2&</td>

View File

@ -168,7 +168,7 @@
<img class="logo" src="assets/logo.png"> <img class="logo" src="assets/logo.png">
<div class="title">systeminformation</div> <div class="title">systeminformation</div>
<div class="subtitle"><span id="typed"></span></div> <div class="subtitle"><span id="typed"></span></div>
<div class="version">Current Version: <span id="version">4.23.7</span></div> <div class="version">Current Version: <span id="version">4.23.8</span></div>
<button class="btn btn-light" onclick="location.href='https://github.com/sebhildebrandt/systeminformation'">View on Github <i class=" fab fa-github"></i></button> <button class="btn btn-light" onclick="location.href='https://github.com/sebhildebrandt/systeminformation'">View on Github <i class=" fab fa-github"></i></button>
</div> </div>
<div class="down"> <div class="down">

View File

@ -64,10 +64,10 @@ function getDefaultNetworkInterface() {
try { try {
if (_windows) { if (_windows) {
// https://www.inetdaemon.com/tutorials/internet/ip/routing/default_route.shtml // https://www.inetdaemon.com/tutorials/internet/ip/routing/default_route.shtml
let defaultIp = '';
const cmd = 'netstat -r'; const cmd = 'netstat -r';
const result = execSync(cmd); const result = execSync(cmd);
const lines = result.toString().split(os.EOL); const lines = result.toString().split(os.EOL);
let defaultIp = '';
lines.forEach(line => { lines.forEach(line => {
line = line.replace(/\s+/g, ' ').trim(); line = line.replace(/\s+/g, ' ').trim();
if (line.indexOf('0.0.0.0 0.0.0.0') > -1 && !(/[a-zA-Z]/.test(line))) { if (line.indexOf('0.0.0.0 0.0.0.0') > -1 && !(/[a-zA-Z]/.test(line))) {
@ -126,6 +126,7 @@ function getMacAddresses() {
pathToIp = ''; pathToIp = '';
} }
} }
try {
const cmd = 'export LC_ALL=C; ' + ((pathToIp) ? pathToIp + ' link show up' : '/sbin/ifconfig') + '; unset LC_ALL'; const cmd = 'export LC_ALL=C; ' + ((pathToIp) ? pathToIp + ' link show up' : '/sbin/ifconfig') + '; unset LC_ALL';
let res = execSync(cmd); let res = execSync(cmd);
const lines = res.toString().split('\n'); const lines = res.toString().split('\n');
@ -150,8 +151,12 @@ function getMacAddresses() {
} }
} }
} }
} catch (e) {
util.noop();
}
} }
if (_darwin) { if (_darwin) {
try {
const cmd = '/sbin/ifconfig'; const cmd = '/sbin/ifconfig';
let res = execSync(cmd); let res = execSync(cmd);
const lines = res.toString().split('\n'); const lines = res.toString().split('\n');
@ -167,6 +172,9 @@ function getMacAddresses() {
} }
} }
} }
} catch (e) {
util.noop();
}
} }
return result; return result;
} }
@ -491,6 +499,7 @@ function getLinuxIfaceConnectionName(interfaceName) {
function checkLinuxDCHPInterfaces(file) { function checkLinuxDCHPInterfaces(file) {
let result = []; let result = [];
try {
let cmd = `cat ${file} 2> /dev/null | grep 'iface\\|source'`; let cmd = `cat ${file} 2> /dev/null | grep 'iface\\|source'`;
const lines = execSync(cmd, { maxBuffer: 1024 * 20000 }).toString().split('\n'); const lines = execSync(cmd, { maxBuffer: 1024 * 20000 }).toString().split('\n');
@ -506,6 +515,9 @@ function checkLinuxDCHPInterfaces(file) {
result = result.concat(checkLinuxDCHPInterfaces(file)); result = result.concat(checkLinuxDCHPInterfaces(file));
} }
}); });
} catch (e) {
util.noop();
}
return result; return result;
} }