From 90a26682720a7a3fcc831d4fbce7deb69b5b24f2 Mon Sep 17 00:00:00 2001 From: Matthew Nickson Date: Wed, 4 Jan 2023 17:32:27 +0000 Subject: [PATCH] Restructured condition + ensure data is UTF-8 Signed-off-by: Matthew Nickson --- server/util-server.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/server/util-server.js b/server/util-server.js index 3549de80a..3f55b3d7d 100644 --- a/server/util-server.js +++ b/server/util-server.js @@ -103,12 +103,10 @@ exports.pingAsync = function (hostname, ipv6 = false) { min_reply: 3 }).then((res) => { // If ping failed, it will set field to unknown - if (!res.alive && res.host === "unknown") { - reject(new Error("Name or service not known")); - } else if (res.time === "unknown") { - reject(new Error(res.output)); - } else { + if (res.alive) { resolve(res.time); + } else { + reject(new Error(exports.convertToUTF8(res.output))); } }).catch((err) => { reject(err);