networkInterfaces() catch errors

This commit is contained in:
Sebastian Hildebrandt 2021-01-12 23:58:27 +01:00
parent 2bc1ee6621
commit 4f60a4c947
4 changed files with 196 additions and 185 deletions

View File

@ -30,6 +30,7 @@ For major (breaking) changes - version 3 and 2 see end of page.
| Version | Date | Comment |
| -------------- | -------------- | -------- |
| 4.34.6 | 2020-01-12 | `networkInterfaces()` catch errors |
| 4.34.5 | 2020-01-07 | `networkInterfaceDefault()` fixed CMD popup (windows) |
| 4.34.4 | 2020-01-06 | `system()` fixed vitrual catch error |
| 4.34.3 | 2020-01-06 | `graphics()` fixed non nvidia-smi controllers (win) |

View File

@ -83,6 +83,11 @@
</tr>
</thead>
<tbody>
<tr>
<th scope="row">4.34.6</th>
<td>2020-01-12</td>
<td><span class="code">networkInterfaces()</span> catch errors</td>
</tr>
<tr>
<th scope="row">4.34.5</th>
<td>2020-01-07</td>

View File

@ -169,7 +169,7 @@
<img class="logo" src="assets/logo.png">
<div class="title">systeminformation</div>
<div class="subtitle"><span id="typed"></span></div>
<div class="version">Current Version: <span id="version">4.34.5</span></div>
<div class="version">Current Version: <span id="version">4.34.6</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>
</div>
<div class="down">
@ -208,7 +208,7 @@
<div class="title">Downloads last month</div>
</div>
<div class="col-xl-4 col-lg-4 col-md-4 col-12">
<div class="numbers">366</div>
<div class="numbers">367</div>
<div class="title">Dependents</div>
</div>
</div>

View File

@ -685,12 +685,13 @@ function networkInterfaces(callback, rescan = true) {
}
return new Promise((resolve) => {
process.nextTick(() => {
let ifaces = os.networkInterfaces();
let result = [];
let nics = [];
let dnsSuffixes = [];
let nics8021xInfo = [];
try {
let ifaces = os.networkInterfaces();
// seperate handling in OSX
if (_darwin || _freebsd || _openbsd || _netbsd) {
nics = getDarwinNics();
@ -917,6 +918,10 @@ function networkInterfaces(callback, rescan = true) {
resolve(result);
}
}
} catch (e) {
if (callback) { callback(result); }
resolve(result);
}
});
});
}