From 92c9b8bb63b563c7a7700929b6f9c42de1f9cbab Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Sat, 4 Mar 2023 20:29:52 +0800 Subject: [PATCH 1/2] Fix ipv6 issue for ping --- server/util-server.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/server/util-server.js b/server/util-server.js index 3d4314d64..9f7805cf9 100644 --- a/server/util-server.js +++ b/server/util-server.js @@ -88,7 +88,14 @@ exports.ping = async (hostname, size = 56) => { } catch (e) { // If the host cannot be resolved, try again with ipv6 // As node-ping does not report a specific error for this, try again with ipv6 no matter what. - return await exports.pingAsync(hostname, true, size); + console.debug("ping", "IPv6 error message: " + e.message); + + if (!e.message) { + // TODO: Problem, the error message is always from the ipv6 ping! Misleading! + return await exports.pingAsync(hostname, true, size); + } else { + throw e; + } } }; From 7ec09d01185bbf35ff9fa2543167376aa0f2d44b Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Sat, 4 Mar 2023 20:41:08 +0800 Subject: [PATCH 2/2] Fix ipv6 issue for ping --- server/util-server.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/server/util-server.js b/server/util-server.js index 9f7805cf9..2cf81f6aa 100644 --- a/server/util-server.js +++ b/server/util-server.js @@ -87,11 +87,10 @@ exports.ping = async (hostname, size = 56) => { return await exports.pingAsync(hostname, false, size); } catch (e) { // If the host cannot be resolved, try again with ipv6 - // As node-ping does not report a specific error for this, try again with ipv6 no matter what. console.debug("ping", "IPv6 error message: " + e.message); + // As node-ping does not report a specific error for this, try again if it is an empty message with ipv6 no matter what. if (!e.message) { - // TODO: Problem, the error message is always from the ipv6 ping! Misleading! return await exports.pingAsync(hostname, true, size); } else { throw e;