systeminformation
Advanced tools
Comparing version 5.23.18 to 5.23.19
@@ -65,48 +65,10 @@ 'use strict'; | ||
} | ||
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; | ||
result.ok = (statusCode === 200 || statusCode === 301 || statusCode === 302 || statusCode === 304); | ||
if (statusCode !== 200) { | ||
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); } | ||
resolve(result); | ||
}); | ||
} | ||
}).on('error', () => { | ||
if (callback) { callback(result); } | ||
resolve(result); | ||
}); | ||
} catch (err) { | ||
if (callback) { callback(result); } | ||
resolve(result); | ||
} | ||
} | ||
util.checkWebsite(urlSanitized).then((res) => { | ||
result.status = res.statusCode; | ||
result.ok = res.statusCode >= 200 && res.statusCode <= 399;; | ||
result.ms = (result.ok ? res.time : null); | ||
if (callback) { callback(result); } | ||
resolve(result); | ||
}); | ||
} else { | ||
@@ -113,0 +75,0 @@ if (callback) { callback(result); } |
@@ -2486,2 +2486,38 @@ 'use strict'; | ||
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() { } | ||
@@ -2540,1 +2576,2 @@ | ||
exports.getAppleModel = getAppleModel; | ||
exports.checkWebsite = checkWebsite; |
{ | ||
"name": "systeminformation", | ||
"version": "5.23.18", | ||
"version": "5.23.19", | ||
"description": "Advanced, lightweight system and OS information library", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Potential vulnerability
Supply chain riskInitial human review suggests the presence of a vulnerability in this package. It is pending further analysis and confirmation.
Found 1 instance in 1 package
35
773561
17061