cpu() refactored using internal node functions
This commit is contained in:
parent
a74b30162f
commit
321408a93d
@ -90,6 +90,7 @@ For major (breaking) changes - **version 4, 3 and 2** - see end of page.
|
|||||||
|
|
||||||
| Version | Date | Comment |
|
| Version | Date | Comment |
|
||||||
| ------- | ---------- | --------------------------------------------------------------------------------------------------- |
|
| ------- | ---------- | --------------------------------------------------------------------------------------------------- |
|
||||||
|
| 5.23.19 | 2024-12-24 | `cpu()` refactored using internal node functions |
|
||||||
| 5.23.18 | 2024-12-24 | `cpu()` Handle RISC-V CPU Manufacturer and Brand |
|
| 5.23.18 | 2024-12-24 | `cpu()` Handle RISC-V CPU Manufacturer and Brand |
|
||||||
| 5.23.17 | 2024-12-23 | `wifiConnections()` refactored - Sequoia compatibel (macOS) |
|
| 5.23.17 | 2024-12-23 | `wifiConnections()` refactored - Sequoia compatibel (macOS) |
|
||||||
| 5.23.16 | 2024-12-22 | `networkConnections()` refactored PID parsing (macOS) |
|
| 5.23.16 | 2024-12-22 | `networkConnections()` refactored PID parsing (macOS) |
|
||||||
|
|||||||
@ -57,7 +57,11 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<th scope="row">5.23.19</th>
|
||||||
|
<td>2024-12-24</td>
|
||||||
|
<td><span class="code">inetChecksite()</span> refactored using internal node functions</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">5.23.18</th>
|
<th scope="row">5.23.18</th>
|
||||||
<td>2024-12-24</td>
|
<td>2024-12-24</td>
|
||||||
|
|||||||
@ -170,7 +170,7 @@
|
|||||||
<img class="logo" src="assets/logo.png" alt="logo">
|
<img class="logo" src="assets/logo.png" alt="logo">
|
||||||
<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">New Version: <span id="version">5.23.18</span></div>
|
<div class="version">New Version: <span id="version">5.23.19</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">
|
||||||
|
|||||||
@ -62,52 +62,14 @@ function inetChecksite(url, callback) {
|
|||||||
if (callback) { callback(result); }
|
if (callback) { callback(result); }
|
||||||
return resolve(result);
|
return resolve(result);
|
||||||
}
|
}
|
||||||
let t = Date.now();
|
|
||||||
if (_linux || _freebsd || _openbsd || _netbsd || _darwin || _sunos) {
|
|
||||||
let args = ['-I', '--connect-timeout', '5', '-m', '5'];
|
|
||||||
args.push(urlSanitized);
|
|
||||||
let cmd = 'curl';
|
|
||||||
util.execSafe(cmd, args).then((stdout) => {
|
|
||||||
const lines = stdout.split('\n');
|
|
||||||
let statusCode = lines[0] && lines[0].indexOf(' ') >= 0 ? parseInt(lines[0].split(' ')[1], 10) : 404;
|
|
||||||
result.status = statusCode || 404;
|
|
||||||
result.ok = (statusCode === 200 || statusCode === 301 || statusCode === 302 || statusCode === 304);
|
|
||||||
result.ms = (result.ok ? Date.now() - t : null);
|
|
||||||
if (callback) { callback(result); }
|
|
||||||
resolve(result);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (_windows) { // if this is stable, this can be used for all OS types
|
|
||||||
const http = (urlSanitized.startsWith('https:') ? require('https') : require('http'));
|
|
||||||
try {
|
|
||||||
http.get(urlSanitized, (res) => {
|
|
||||||
const statusCode = res.statusCode;
|
|
||||||
|
|
||||||
result.status = statusCode || 404;
|
util.checkWebsite(urlSanitized).then((res) => {
|
||||||
result.ok = (statusCode === 200 || statusCode === 301 || statusCode === 302 || statusCode === 304);
|
result.status = res.statusCode;
|
||||||
|
result.ok = res.statusCode >= 200 && res.statusCode <= 399;;
|
||||||
if (statusCode !== 200) {
|
result.ms = (result.ok ? res.time : null);
|
||||||
res.resume();
|
|
||||||
result.ms = (result.ok ? Date.now() - t : null);
|
|
||||||
if (callback) { callback(result); }
|
|
||||||
resolve(result);
|
|
||||||
} else {
|
|
||||||
res.on('data', () => { });
|
|
||||||
res.on('end', () => {
|
|
||||||
result.ms = (result.ok ? Date.now() - t : null);
|
|
||||||
if (callback) { callback(result); }
|
if (callback) { callback(result); }
|
||||||
resolve(result);
|
resolve(result);
|
||||||
});
|
});
|
||||||
}
|
|
||||||
}).on('error', () => {
|
|
||||||
if (callback) { callback(result); }
|
|
||||||
resolve(result);
|
|
||||||
});
|
|
||||||
} catch (err) {
|
|
||||||
if (callback) { callback(result); }
|
|
||||||
resolve(result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (callback) { callback(result); }
|
if (callback) { callback(result); }
|
||||||
resolve(result);
|
resolve(result);
|
||||||
|
|||||||
37
lib/util.js
37
lib/util.js
@ -2483,6 +2483,42 @@ function getAppleModel(key) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function checkWebsite(url, timeout = 5000) {
|
||||||
|
const http = ((url.startsWith('https:') || url.indexOf(':443/') > 0 || url.indexOf(':8443/') > 0) ? require('https') : require('http'));
|
||||||
|
const t = Date.now();
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
http
|
||||||
|
.get(url, { rejectUnauthorized: false }, function (res) {
|
||||||
|
res.on('data', () => { });
|
||||||
|
res.on('end', () => {
|
||||||
|
resolve({
|
||||||
|
url,
|
||||||
|
statusCode: res.statusCode,
|
||||||
|
message: res.statusMessage,
|
||||||
|
time: Date.now() - t
|
||||||
|
});
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.on("error", function (e) {
|
||||||
|
resolve({
|
||||||
|
url,
|
||||||
|
statusCode: 404,
|
||||||
|
message: e.message,
|
||||||
|
time: Date.now() - t
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.setTimeout(timeout, () => {
|
||||||
|
request.close();
|
||||||
|
resolve({
|
||||||
|
url,
|
||||||
|
statusCode: 408,
|
||||||
|
message: 'Request Timeout',
|
||||||
|
time: Date.now() - t
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
function noop() { }
|
function noop() { }
|
||||||
|
|
||||||
exports.toInt = toInt;
|
exports.toInt = toInt;
|
||||||
@ -2536,3 +2572,4 @@ exports.WINDIR = WINDIR;
|
|||||||
exports.getFilesInPath = getFilesInPath;
|
exports.getFilesInPath = getFilesInPath;
|
||||||
exports.semverCompare = semverCompare;
|
exports.semverCompare = semverCompare;
|
||||||
exports.getAppleModel = getAppleModel;
|
exports.getAppleModel = getAppleModel;
|
||||||
|
exports.checkWebsite = checkWebsite;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user