This commit is contained in:
Sebastian Hildebrandt 2020-02-02 16:18:31 +01:00
commit a7a4959f11
6 changed files with 53 additions and 27 deletions

View File

@ -30,6 +30,9 @@ For major (breaking) changes - version 3 and 2 see end of page.
| Version | Date | Comment | | Version | Date | Comment |
| -------------- | -------------- | -------- | | -------------- | -------------- | -------- |
| 4.21.1 | 2020-01-31 | `networkGatewayDefault()` fixed windows 7 issue |
| 4.21.0 | 2020-01-27 | `npx` compatibility |
| 4.20.1 | 2020-01-26 | `battery()` code refactoring, cleanup, updated docs |
| 4.20.1 | 2020-01-26 | `battery()` code refactoring, cleanup, updated docs | | 4.20.1 | 2020-01-26 | `battery()` code refactoring, cleanup, updated docs |
| 4.20.0 | 2020-01-25 | `battery()` added designcapacity, voltage, unit | | 4.20.0 | 2020-01-25 | `battery()` added designcapacity, voltage, unit |
| 4.19.4 | 2020-01-24 | `mem()` prevent log messages, `memgetDefaultNetworkInterface()` catch errors | | 4.19.4 | 2020-01-24 | `mem()` prevent log messages, `memgetDefaultNetworkInterface()` catch errors |

View File

@ -83,6 +83,11 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr>
<th scope="row">4.21.1</th>
<td>2020-01-31</td>
<td><span class="code">networkGatewayDefault()</span> fixed windows 7 issue</td>
</tr>
<tr> <tr>
<th scope="row">4.21.0</th> <th scope="row">4.21.0</th>
<td>2020-01-27</td> <td>2020-01-27</td>

View File

@ -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.21.0</span></div> <div class="version">Current Version: <span id="version">4.21.1</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">
@ -206,7 +206,7 @@
<div class="title">Downloads last month</div> <div class="title">Downloads last month</div>
</div> </div>
<div class="col-xl-4 col-lg-4 col-md-4 col-12"> <div class="col-xl-4 col-lg-4 col-md-4 col-12">
<div class="numbers">242</div> <div class="numbers">244</div>
<div class="title">Dependends</div> <div class="title">Dependends</div>
</div> </div>
</div> </div>

View File

@ -564,7 +564,7 @@
It is determined by calculating the difference of cpu ticks between two calls of the function.</p> It is determined by calculating the difference of cpu ticks between two calls of the function.</p>
<p>The first time you are calling one of this functions, you will get the load since cpu uptime. <p>The first time you are calling one of this functions, you will get the load since cpu uptime.
The second time, you should then get statistics based cpu ticks between the two calls ...</p> The second time, you should then get statistics based on cpu ticks between the two calls ...</p>
<p>So basically, your code should look like this:</p> <p>So basically, your code should look like this:</p>

View File

@ -1402,32 +1402,50 @@ function networkGatewayDefault(callback) {
} }
if (_windows) { if (_windows) {
try { try {
util.powerShell('Get-CimInstance -ClassName Win32_IP4RouteTable | Where-Object { $_.Destination -eq \'0.0.0.0\' -and $_.Mask -eq \'0.0.0.0\' }') exec('netstat -r', util.execOptsWin, function (error, stdout) {
.then(data => { const lines = stdout.toString().split(os.EOL);
let lines = data.toString().split('\r\n'); lines.forEach(line => {
if (lines.length > 1 && !result) { line = line.replace(/\s+/g, ' ').trim();
result = util.getValue(lines, 'NextHop'); if (line.indexOf('0.0.0.0 0.0.0.0') > -1 && !(/[a-zA-Z]/.test(line))) {
// result = lines && lines[0] ? lines[0] : ''; const parts = line.split(' ');
if (callback) { if (parts.length >= 5 && (parts[parts.length - 3]).indexOf('.') > -1) {
callback(result); result = parts[parts.length - 3];
} }
resolve(result);
} else {
exec('ipconfig', util.execOptsWin, function (error, stdout) {
let lines = stdout.toString().split('\r\n');
lines.forEach(function (line) {
line = line.trim().replace(/\. /g, '');
line = line.trim().replace(/ +/g, '');
const parts = line.split(':');
if (parts[0].toLowerCase().startsWith('standardgate') && parts[1]) {
result = parts[1];
}
});
if (callback) { callback(result); }
resolve(result);
});
} }
}); });
if (!result) {
util.powerShell('Get-CimInstance -ClassName Win32_IP4RouteTable | Where-Object { $_.Destination -eq \'0.0.0.0\' -and $_.Mask -eq \'0.0.0.0\' }')
.then(data => {
let lines = data.toString().split('\r\n');
if (lines.length > 1 && !result) {
result = util.getValue(lines, 'NextHop');
if (callback) {
callback(result);
}
resolve(result);
// } else {
// exec('ipconfig', util.execOptsWin, function (error, stdout) {
// let lines = stdout.toString().split('\r\n');
// lines.forEach(function (line) {
// line = line.trim().replace(/\. /g, '');
// line = line.trim().replace(/ +/g, '');
// const parts = line.split(':');
// if ((parts[0].toLowerCase().startsWith('standardgate') || parts[0].toLowerCase().indexOf('gateway') > -1 || parts[0].toLowerCase().indexOf('enlace') > -1) && parts[1]) {
// result = parts[1];
// }
// });
// if (callback) { callback(result); }
// resolve(result);
// });
}
});
} else {
if (callback) {
callback(result);
}
resolve(result);
}
});
} catch (e) { } catch (e) {
if (callback) { callback(result); } if (callback) { callback(result); }
resolve(result); resolve(result);

View File

@ -1,6 +1,6 @@
{ {
"name": "systeminformation", "name": "systeminformation",
"version": "4.21.0", "version": "4.21.1",
"description": "Simple system and OS information library", "description": "Simple system and OS information library",
"license": "MIT", "license": "MIT",
"author": "Sebastian Hildebrandt <hildebrandt@plus-innovations.com> (https://plus-innovations.com)", "author": "Sebastian Hildebrandt <hildebrandt@plus-innovations.com> (https://plus-innovations.com)",