getMacAddresses() fix added try catch
This commit is contained in:
parent
d8fc1520ec
commit
3d61fe987c
@ -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 |
|
||||||
|
|||||||
@ -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>
|
||||||
|
|||||||
@ -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">
|
||||||
|
|||||||
102
lib/network.js
102
lib/network.js
@ -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,46 +126,54 @@ function getMacAddresses() {
|
|||||||
pathToIp = '';
|
pathToIp = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const cmd = 'export LC_ALL=C; ' + ((pathToIp) ? pathToIp + ' link show up' : '/sbin/ifconfig') + '; unset LC_ALL';
|
try {
|
||||||
let res = execSync(cmd);
|
const cmd = 'export LC_ALL=C; ' + ((pathToIp) ? pathToIp + ' link show up' : '/sbin/ifconfig') + '; unset LC_ALL';
|
||||||
const lines = res.toString().split('\n');
|
let res = execSync(cmd);
|
||||||
for (let i = 0; i < lines.length; i++) {
|
const lines = res.toString().split('\n');
|
||||||
if (lines[i] && lines[i][0] !== ' ') {
|
for (let i = 0; i < lines.length; i++) {
|
||||||
if (pathToIp) {
|
if (lines[i] && lines[i][0] !== ' ') {
|
||||||
let nextline = lines[i + 1].trim().split(' ');
|
if (pathToIp) {
|
||||||
if (nextline[0] === 'link/ether') {
|
let nextline = lines[i + 1].trim().split(' ');
|
||||||
iface = lines[i].split(' ')[1];
|
if (nextline[0] === 'link/ether') {
|
||||||
iface = iface.slice(0, iface.length - 1);
|
iface = lines[i].split(' ')[1];
|
||||||
mac = nextline[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) {
|
if (iface && mac) {
|
||||||
result[iface] = mac.trim();
|
result[iface] = mac.trim();
|
||||||
iface = '';
|
iface = '';
|
||||||
mac = '';
|
mac = '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (e) {
|
||||||
|
util.noop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (_darwin) {
|
if (_darwin) {
|
||||||
const cmd = '/sbin/ifconfig';
|
try {
|
||||||
let res = execSync(cmd);
|
const cmd = '/sbin/ifconfig';
|
||||||
const lines = res.toString().split('\n');
|
let res = execSync(cmd);
|
||||||
for (let i = 0; i < lines.length; i++) {
|
const lines = res.toString().split('\n');
|
||||||
if (lines[i] && lines[i][0] !== '\t' && lines[i].indexOf(':') > 0) {
|
for (let i = 0; i < lines.length; i++) {
|
||||||
iface = lines[i].split(':')[0];
|
if (lines[i] && lines[i][0] !== '\t' && lines[i].indexOf(':') > 0) {
|
||||||
} else if (lines[i].indexOf('\tether ') === 0) {
|
iface = lines[i].split(':')[0];
|
||||||
mac = lines[i].split('\tether ')[1];
|
} else if (lines[i].indexOf('\tether ') === 0) {
|
||||||
if (iface && mac) {
|
mac = lines[i].split('\tether ')[1];
|
||||||
result[iface] = mac.trim();
|
if (iface && mac) {
|
||||||
iface = '';
|
result[iface] = mac.trim();
|
||||||
mac = '';
|
iface = '';
|
||||||
|
mac = '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (e) {
|
||||||
|
util.noop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@ -491,21 +499,25 @@ function getLinuxIfaceConnectionName(interfaceName) {
|
|||||||
|
|
||||||
function checkLinuxDCHPInterfaces(file) {
|
function checkLinuxDCHPInterfaces(file) {
|
||||||
let result = [];
|
let result = [];
|
||||||
let cmd = `cat ${file} 2> /dev/null | grep 'iface\\|source'`;
|
try {
|
||||||
const lines = execSync(cmd, { maxBuffer: 1024 * 20000 }).toString().split('\n');
|
let cmd = `cat ${file} 2> /dev/null | grep 'iface\\|source'`;
|
||||||
|
const lines = execSync(cmd, { maxBuffer: 1024 * 20000 }).toString().split('\n');
|
||||||
|
|
||||||
lines.forEach(line => {
|
lines.forEach(line => {
|
||||||
const parts = line.replace(/\s+/g, ' ').trim().split(' ');
|
const parts = line.replace(/\s+/g, ' ').trim().split(' ');
|
||||||
if (parts.length >= 4) {
|
if (parts.length >= 4) {
|
||||||
if (line.toLowerCase().indexOf(' inet ') >= 0 && line.toLowerCase().indexOf('dhcp') >= 0) {
|
if (line.toLowerCase().indexOf(' inet ') >= 0 && line.toLowerCase().indexOf('dhcp') >= 0) {
|
||||||
result.push(parts[1]);
|
result.push(parts[1]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
if (line.toLowerCase().includes('source')) {
|
||||||
if (line.toLowerCase().includes('source')) {
|
let file = line.split(' ')[1];
|
||||||
let file = line.split(' ')[1];
|
result = result.concat(checkLinuxDCHPInterfaces(file));
|
||||||
result = result.concat(checkLinuxDCHPInterfaces(file));
|
}
|
||||||
}
|
});
|
||||||
});
|
} catch (e) {
|
||||||
|
util.noop();
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user