mirror of
https://github.com/nodejs/node.git
synced 2026-10-14 10:26:26 -04:00
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:
1 parent
8c04b45247
commit
053f36855a
1 file changed
+5
-3
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user