networkInterfaceDefault() fix windows
This commit is contained in:
parent
abf330afb5
commit
32672755b2
@ -30,6 +30,7 @@ For major (breaking) changes - version 3 and 2 see end of page.
|
|||||||
|
|
||||||
| Version | Date | Comment |
|
| Version | Date | Comment |
|
||||||
| -------------- | -------------- | -------- |
|
| -------------- | -------------- | -------- |
|
||||||
|
| 4.0.10 | 2019-02-10 | `networkInterfaceDefault()` fix windows |
|
||||||
| 4.0.9 | 2019-02-08 | `cpu()` fix, code cleanup |
|
| 4.0.9 | 2019-02-08 | `cpu()` fix, code cleanup |
|
||||||
| 4.0.8 | 2019-02-05 | `inetLatency()` Windows fix parse chinese output |
|
| 4.0.8 | 2019-02-05 | `inetLatency()` Windows fix parse chinese output |
|
||||||
| 4.0.7 | 2019-02-05 | `inetLatency()` Windows fix |
|
| 4.0.7 | 2019-02-05 | `inetLatency()` Windows fix |
|
||||||
|
|||||||
@ -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].speed | X | | | X | | speed in MBit / s |
|
||||||
| | [0].carrierChanges | X | | | | | # changes up/down |
|
| | [0].carrierChanges | X | | | | | # changes up/down |
|
||||||
| si.networkInterfaceDefault(cb) | : string | X | X | X | X | X | get name of default network interface |
|
| 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].iface | X | X | X | X | | interface |
|
||||||
| | [0].operstate | X | X | X | X | | up / down |
|
| | [0].operstate | X | X | X | X | | up / down |
|
||||||
| | [0].rx_bytes | X | X | X | X | | received bytes overall |
|
| | [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 |
|
| Function | Result object | Linux | BSD | Mac | Win | Sun | Comments |
|
||||||
| --------------- | ------------- | ----- | ------- | --- | --- | --- | -------- |
|
| --------------- | ------------- | ----- | ------- | --- | --- | --- | -------- |
|
||||||
| si.getStaticData(cb) | {...} | X | X | X | X | X | all static data at once |
|
| 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.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 |
|
| 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)
|
### cb: Asynchronous Function Calls (callback)
|
||||||
|
|
||||||
|
|||||||
@ -162,7 +162,7 @@
|
|||||||
<td>X</td>
|
<td>X</td>
|
||||||
<td>X</td>
|
<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>
|
||||||
<tr>
|
<tr>
|
||||||
<td>si.getAllData(srv,iface,cb)</td>
|
<td>si.getAllData(srv,iface,cb)</td>
|
||||||
@ -172,7 +172,7 @@
|
|||||||
<td>X</td>
|
<td>X</td>
|
||||||
<td>X</td>
|
<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>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
@ -80,6 +80,11 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<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>
|
<tr>
|
||||||
<th scope="row">4.0.9</th>
|
<th scope="row">4.0.9</th>
|
||||||
<td>2019-02-08</td>
|
<td>2019-02-08</td>
|
||||||
|
|||||||
@ -170,7 +170,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.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>
|
<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">
|
||||||
|
|||||||
@ -215,7 +215,7 @@ h1, h2, h3, h4 {
|
|||||||
|
|
||||||
.nav .logo {
|
.nav .logo {
|
||||||
width: 60px;
|
width: 60px;
|
||||||
margin-top: 10px;
|
margin-top: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.nav .title {
|
.nav .title {
|
||||||
|
|||||||
@ -144,7 +144,7 @@ h1, h2, h3, h4 {
|
|||||||
position: relative;
|
position: relative;
|
||||||
.logo {
|
.logo {
|
||||||
width: 60px;
|
width: 60px;
|
||||||
margin-top: 10px;
|
margin-top: 12px;
|
||||||
}
|
}
|
||||||
.title {
|
.title {
|
||||||
display: none;
|
display: none;
|
||||||
|
|||||||
@ -28,7 +28,7 @@ const _openbsd = (_platform === 'openbsd');
|
|||||||
const _sunos = (_platform === 'sunos');
|
const _sunos = (_platform === 'sunos');
|
||||||
|
|
||||||
let _network = {};
|
let _network = {};
|
||||||
let _default_iface;
|
let _default_iface = '';
|
||||||
let _ifaces = [];
|
let _ifaces = [];
|
||||||
let _networkInterfaces = [];
|
let _networkInterfaces = [];
|
||||||
let _mac = {};
|
let _mac = {};
|
||||||
@ -38,19 +38,25 @@ function getDefaultNetworkInterface() {
|
|||||||
|
|
||||||
let ifaces = os.networkInterfaces();
|
let ifaces = os.networkInterfaces();
|
||||||
let ifacename = '';
|
let ifacename = '';
|
||||||
|
let ifacenameFirst = '';
|
||||||
|
|
||||||
let scopeid = 9999;
|
let scopeid = 9999;
|
||||||
|
|
||||||
// fallback - "first" external interface (sorted by scopeid)
|
// fallback - "first" external interface (sorted by scopeid)
|
||||||
for (let dev in ifaces) {
|
for (let dev in ifaces) {
|
||||||
if (ifaces.hasOwnProperty(dev)) {
|
if (ifaces.hasOwnProperty(dev)) {
|
||||||
ifaces[dev].forEach(function (details) {
|
ifaces[dev].forEach(function (details) {
|
||||||
if (details && details.internal === false && details.scopeid && details.scopeid < scopeid) {
|
if (details && details.internal === false) {
|
||||||
|
ifacenameFirst = ifacenameFirst || dev; // fallback if no scopeid
|
||||||
|
if (details.scopeid && details.scopeid < scopeid) {
|
||||||
ifacename = dev;
|
ifacename = dev;
|
||||||
scopeid = details.scopeid;
|
scopeid = details.scopeid;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ifacename = ifacename || ifacenameFirst || '';
|
||||||
if (_linux || _darwin || _freebsd || _openbsd || _sunos) {
|
if (_linux || _darwin || _freebsd || _openbsd || _sunos) {
|
||||||
let cmd = '';
|
let cmd = '';
|
||||||
if (_linux) cmd = 'route 2>/dev/null | grep default | awk \'{print $8}\'';
|
if (_linux) cmd = 'route 2>/dev/null | grep default | awk \'{print $8}\'';
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user