baseboard(), getDefaultNetworkInterface() fix catch error
This commit is contained in:
+20
-20
@@ -39,29 +39,29 @@ let pathToIp;
|
||||
|
||||
function getDefaultNetworkInterface() {
|
||||
|
||||
let ifaces = os.networkInterfaces();
|
||||
let ifacename = '';
|
||||
let ifacenameFirst = '';
|
||||
|
||||
let scopeid = 9999;
|
||||
|
||||
// fallback - "first" external interface (sorted by scopeid)
|
||||
for (let dev in ifaces) {
|
||||
if ({}.hasOwnProperty.call(ifaces, dev)) {
|
||||
ifaces[dev].forEach(function (details) {
|
||||
if (details && details.internal === false) {
|
||||
ifacenameFirst = ifacenameFirst || dev; // fallback if no scopeid
|
||||
if (details.scopeid && details.scopeid < scopeid) {
|
||||
ifacename = dev;
|
||||
scopeid = details.scopeid;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
ifacename = ifacename || ifacenameFirst || '';
|
||||
|
||||
try {
|
||||
let ifaces = os.networkInterfaces();
|
||||
|
||||
let scopeid = 9999;
|
||||
|
||||
// fallback - "first" external interface (sorted by scopeid)
|
||||
for (let dev in ifaces) {
|
||||
if ({}.hasOwnProperty.call(ifaces, dev)) {
|
||||
ifaces[dev].forEach(function (details) {
|
||||
if (details && details.internal === false) {
|
||||
ifacenameFirst = ifacenameFirst || dev; // fallback if no scopeid
|
||||
if (details.scopeid && details.scopeid < scopeid) {
|
||||
ifacename = dev;
|
||||
scopeid = details.scopeid;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
ifacename = ifacename || ifacenameFirst || '';
|
||||
|
||||
if (_windows) {
|
||||
// https://www.inetdaemon.com/tutorials/internet/ip/routing/default_route.shtml
|
||||
let defaultIp = '';
|
||||
|
||||
+6
-1
@@ -615,7 +615,12 @@ function baseboard(callback) {
|
||||
result.memSlots = util.toInt(util.getValue(lines, 'Number Of Devices')) || null;
|
||||
|
||||
// raspberry
|
||||
const linesRpi = fs.readFileSync('/proc/cpuinfo').toString().split('\n');
|
||||
let linesRpi = '';
|
||||
try {
|
||||
linesRpi = fs.readFileSync('/proc/cpuinfo').toString().split('\n');
|
||||
} catch (e) {
|
||||
util.noop();
|
||||
}
|
||||
const hardware = util.getValue(linesRpi, 'hardware');
|
||||
if (hardware.startsWith('BCM')) {
|
||||
const rpi = util.decodePiCpuinfo(linesRpi);
|
||||
|
||||
+1
-1
@@ -112,7 +112,7 @@ function getValue(lines, property, separator, trimmed) {
|
||||
if (trimmed) {
|
||||
line = line.trim();
|
||||
}
|
||||
if (line.startsWith(property) && line.match(property + separator)) {
|
||||
if (line.startsWith(property)) {
|
||||
const parts = trimmed ? lines[i].trim().split(separator) : lines[i].split(separator);
|
||||
if (parts.length >= 2) {
|
||||
parts.shift();
|
||||
|
||||
Reference in New Issue
Block a user