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 <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
This commit is contained in:
Luigi Pinca authored and GitHub committed 2023-11-21 20:56:02 +00:00
1 parent 8c04b45247
commit 053f36855a
1 file changed
+5 -3
+5 -3
View File
@@ -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);