From d5c16f897ad93ef9522ff815167c955e64f24f69 Mon Sep 17 00:00:00 2001 From: Luigi Pinca Date: Tue, 21 Nov 2023 21:56:02 +0100 Subject: [PATCH] dns: call handle.setServers() with a valid array `handle.setServers()` takes an array, not a string. PR-URL: https://github.com/nodejs/node/pull/50811 Reviewed-By: James M Snell Reviewed-By: Matteo Collina Reviewed-By: Marco Ippolito --- lib/internal/dns/utils.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/internal/dns/utils.js b/lib/internal/dns/utils.js index fa8f0b8cf14103..0d1f817593f2e7 100644 --- a/lib/internal/dns/utils.js +++ b/lib/internal/dns/utils.js @@ -2,7 +2,6 @@ const { ArrayPrototypeForEach, - ArrayPrototypeJoin, ArrayPrototypeMap, ArrayPrototypePush, FunctionPrototypeBind, @@ -143,12 +142,15 @@ class ResolverBase { } [kSetServersInteral](newSet, servers) { - const orig = this._handle.getServers() || []; + const orig = ArrayPrototypeMap(this._handle.getServers() || [], (val) => { + val.unshift(isIP(val[0])); + return val; + }); const errorNumber = this._handle.setServers(newSet); if (errorNumber !== 0) { // Reset the servers to the old servers, because ares probably unset them. - this._handle.setServers(ArrayPrototypeJoin(orig, ',')); + this._handle.setServers(orig); const { strerror } = lazyBinding(); const err = strerror(errorNumber); throw new ERR_DNS_SET_SERVERS_FAILED(err, servers);