inetLatency() fix for alpine (linux)
This commit is contained in:
parent
3f24b4970d
commit
dd2515a169
@ -158,24 +158,20 @@ function inetLatency(host, callback) {
|
||||
return resolve(null);
|
||||
}
|
||||
let params;
|
||||
let filt;
|
||||
if (_linux || _freebsd || _openbsd || _netbsd || _darwin) {
|
||||
if (_linux) {
|
||||
params = ['-c', '2', '-w', '3', hostSanitized];
|
||||
filt = 'rtt';
|
||||
}
|
||||
if (_freebsd || _openbsd || _netbsd) {
|
||||
params = ['-c', '2', '-t', '3', hostSanitized];
|
||||
filt = 'round-trip';
|
||||
}
|
||||
if (_darwin) {
|
||||
params = ['-c2', '-t3', hostSanitized];
|
||||
filt = 'avg';
|
||||
}
|
||||
util.execSafe('ping', params).then((stdout) => {
|
||||
let result = null;
|
||||
if (stdout) {
|
||||
const lines = stdout.split('\n').filter(line => line.indexOf(filt) >= 0).join('\n');
|
||||
const lines = stdout.split('\n').filter((line) => (line.indexOf('rtt') >= 0 || line.indexOf('round-trip') >= 0 || line.indexOf('avg') >= 0)).join('\n');
|
||||
|
||||
const line = lines.split('=');
|
||||
if (line.length > 1) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user