From 527e0c34447726c74e89284fd4278dabc258e902 Mon Sep 17 00:00:00 2001 From: LouisLam Date: Tue, 31 Aug 2021 22:14:33 +0800 Subject: [PATCH] raise the ping timeout from 2s to 10s (avoid #294) --- server/ping-lite.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/server/ping-lite.js b/server/ping-lite.js index ec2cd8322..0af0e9706 100644 --- a/server/ping-lite.js +++ b/server/ping-lite.js @@ -21,15 +21,17 @@ function Ping(host, options) { events.EventEmitter.call(this); + const timeout = 10; + if (WIN) { this._bin = "c:/windows/system32/ping.exe"; - this._args = (options.args) ? options.args : [ "-n", "1", "-w", "5000", host ]; + this._args = (options.args) ? options.args : [ "-n", "1", "-w", timeout * 1000, host ]; this._regmatch = /[><=]([0-9.]+?)ms/; } else if (LIN) { this._bin = "/bin/ping"; - const defaultArgs = [ "-n", "-w", "2", "-c", "1", host ]; + const defaultArgs = [ "-n", "-w", timeout, "-c", "1", host ]; if (net.isIPv6(host) || options.ipv6) { defaultArgs.unshift("-6"); @@ -46,13 +48,13 @@ function Ping(host, options) { this._bin = "/sbin/ping"; } - this._args = (options.args) ? options.args : [ "-n", "-t", "2", "-c", "1", host ]; + this._args = (options.args) ? options.args : [ "-n", "-t", timeout, "-c", "1", host ]; this._regmatch = /=([0-9.]+?) ms/; } else if (FBSD) { this._bin = "/sbin/ping"; - const defaultArgs = [ "-n", "-t", "2", "-c", "1", host ]; + const defaultArgs = [ "-n", "-t", timeout, "-c", "1", host ]; if (net.isIPv6(host) || options.ipv6) { defaultArgs.unshift("-6");