Skip to content

Commit d5c16f8

Browse files
lpincaUlisesGascon
authored andcommitted
dns: call handle.setServers() with a valid array
`handle.setServers()` takes an array, not a string. PR-URL: #50811 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
1 parent 833190f commit d5c16f8

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/internal/dns/utils.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
const {
44
ArrayPrototypeForEach,
5-
ArrayPrototypeJoin,
65
ArrayPrototypeMap,
76
ArrayPrototypePush,
87
FunctionPrototypeBind,
@@ -143,12 +142,15 @@ class ResolverBase {
143142
}
144143

145144
[kSetServersInteral](newSet, servers) {
146-
const orig = this._handle.getServers() || [];
145+
const orig = ArrayPrototypeMap(this._handle.getServers() || [], (val) => {
146+
val.unshift(isIP(val[0]));
147+
return val;
148+
});
147149
const errorNumber = this._handle.setServers(newSet);
148150

149151
if (errorNumber !== 0) {
150152
// Reset the servers to the old servers, because ares probably unset them.
151-
this._handle.setServers(ArrayPrototypeJoin(orig, ','));
153+
this._handle.setServers(orig);
152154
const { strerror } = lazyBinding();
153155
const err = strerror(errorNumber);
154156
throw new ERR_DNS_SET_SERVERS_FAILED(err, servers);

0 commit comments

Comments
 (0)