From 01e9c76a6fe012bc8b1c8e2225c4956bbd897619 Mon Sep 17 00:00:00 2001 From: AverageHumanoid Date: Mon, 16 Aug 2021 19:48:37 -0700 Subject: [PATCH] Use ping in FreeBSD --- server/ping-lite.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/server/ping-lite.js b/server/ping-lite.js index 4e0874d26..42a704e0c 100644 --- a/server/ping-lite.js +++ b/server/ping-lite.js @@ -7,6 +7,7 @@ const spawn = require("child_process").spawn, WIN = /^win/.test(process.platform), LIN = /^linux/.test(process.platform), MAC = /^darwin/.test(process.platform); + FBSD = /^freebsd/.test(process.platform); const { debug } = require("../src/util"); module.exports = Ping; @@ -48,6 +49,18 @@ function Ping(host, options) { this._args = (options.args) ? options.args : [ "-n", "-t", "2", "-c", "1", host ]; this._regmatch = /=([0-9.]+?) ms/; + + } else if (FBSD) { + this._bin = "/sbin/ping"; + + const defaultArgs = [ "-n", "-t", "2", "-c", "1", host ]; + + if (net.isIPv6(host) || options.ipv6) { + defaultArgs.unshift("-6"); + } + + this._args = (options.args) ? options.args : defaultArgs; + this._regmatch = /=([0-9.]+?) ms/; } else { throw new Error("Could not detect your ping binary.");