networkInterfaceDefault() fix windows

This commit is contained in:
Sebastian Hildebrandt 2019-02-10 10:19:59 +01:00
parent abf330afb5
commit 32672755b2
8 changed files with 24 additions and 12 deletions

View File

@ -30,6 +30,7 @@ For major (breaking) changes - version 3 and 2 see end of page.
| Version | Date | Comment |
| -------------- | -------------- | -------- |
| 4.0.10 | 2019-02-10 | `networkInterfaceDefault()` fix windows |
| 4.0.9 | 2019-02-08 | `cpu()` fix, code cleanup |
| 4.0.8 | 2019-02-05 | `inetLatency()` Windows fix parse chinese output |
| 4.0.7 | 2019-02-05 | `inetLatency()` Windows fix |

View File

@ -413,7 +413,7 @@ I also created a nice little command line tool called [mmon][mmon-github-url] (
| | [0].speed | X | | | X | | speed in MBit / s |
| | [0].carrierChanges | X | | | | | # changes up/down |
| si.networkInterfaceDefault(cb) | : string | X | X | X | X | X | get name of default network interface |
| si.networkStats(ifaces,cb) | [{...}] | X | X | X | X | | current network stats of given interfaces<br>iface list: space or comma separated<br>iface parameter is optional<br>defaults to first external network interface,<br />pass '*' for all interfaces |
| si.networkStats(ifaces,cb) | [{...}] | X | X | X | X | | current network stats of given interfaces<br>iface list: space or comma separated<br>iface parameter is optional<br>defaults to first external network interface,<br />Pass '*' for all interfaces |
| | [0].iface | X | X | X | X | | interface |
| | [0].operstate | X | X | X | X | | up / down |
| | [0].rx_bytes | X | X | X | X | | received bytes overall |
@ -490,8 +490,8 @@ I also created a nice little command line tool called [mmon][mmon-github-url] (
| Function | Result object | Linux | BSD | Mac | Win | Sun | Comments |
| --------------- | ------------- | ----- | ------- | --- | --- | --- | -------- |
| si.getStaticData(cb) | {...} | X | X | X | X | X | all static data at once |
| si.getDynamicData(srv,iface,cb) | {...} | X | X | X | X | X | all dynamic data at once |
| si.getAllData(srv,iface,cb) | {...} | X | X | X | X | X | all data at once |
| si.getDynamicData(srv,iface,cb) | {...} | X | X | X | X | X | all dynamic data at once<br>Specify services and interfaces to monitor<br>Defaults to first external network interface<br>Pass "*" for ALL services (linux/win only)<br>Pass "*" for ALL network interfaces |
| si.getAllData(srv,iface,cb) | {...} | X | X | X | X | X | all data at once<br>Specify services and interfaces to monitor<br>Defaults to first external network interface<br>Pass "*" for ALL services (linux/win only)<br>Pass "*" for ALL network interfaces |
### cb: Asynchronous Function Calls (callback)

View File

@ -162,7 +162,7 @@
<td>X</td>
<td>X</td>
<td>X</td>
<td>all dynamic data at once</td>
<td>all dynamic data at once<br>Specify services and interfaces to monitor<br>Defaults to first external network interface<br>Pass "*" for ALL services (linux/win only)<br>Pass "*" for ALL network interfaces</td>
</tr>
<tr>
<td>si.getAllData(srv,iface,cb)</td>
@ -172,7 +172,7 @@
<td>X</td>
<td>X</td>
<td>X</td>
<td>all data at once</td>
<td>all data at once<br>Specify services and interfaces to monitor<br>Defaults to first external network interface<br>Pass "*" for ALL services (linux/win only)<br>Pass "*" for ALL network interfaces</td>
</tr>
</tbody>
</table>

View File

@ -80,6 +80,11 @@
</tr>
</thead>
<tbody>
<tr>
<th scope="row">4.0.10</th>
<td>2019-02-10</td>
<td><span class="code">networkInterfaceDefault()</span> fix windows</td>
</tr>
<tr>
<th scope="row">4.0.9</th>
<td>2019-02-08</td>

View File

@ -170,7 +170,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.0.9</span></div>
<div class="version">Current Version: <span id="version">4.0.10</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">

View File

@ -215,7 +215,7 @@ h1, h2, h3, h4 {
.nav .logo {
width: 60px;
margin-top: 10px;
margin-top: 12px;
}
.nav .title {

View File

@ -144,7 +144,7 @@ h1, h2, h3, h4 {
position: relative;
.logo {
width: 60px;
margin-top: 10px;
margin-top: 12px;
}
.title {
display: none;

View File

@ -28,7 +28,7 @@ const _openbsd = (_platform === 'openbsd');
const _sunos = (_platform === 'sunos');
let _network = {};
let _default_iface;
let _default_iface = '';
let _ifaces = [];
let _networkInterfaces = [];
let _mac = {};
@ -38,19 +38,25 @@ 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 (ifaces.hasOwnProperty(dev)) {
ifaces[dev].forEach(function (details) {
if (details && details.internal === false && details.scopeid && details.scopeid < scopeid) {
ifacename = dev;
scopeid = details.scopeid;
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 (_linux || _darwin || _freebsd || _openbsd || _sunos) {
let cmd = '';
if (_linux) cmd = 'route 2>/dev/null | grep default | awk \'{print $8}\'';