dnsPromises.setServers(servers)
servers<string[]> RFC 5952 格式地址的数组
设置在执行 DNS 解析时要使用的服务器的 IP 地址和端口。servers 参数是一个 RFC 5952 格式地址的数组。如果端口是 IANA 默认的 DNS 端口(53),可以省略不写。
【Sets the IP address and port of servers to be used when performing DNS
resolution. The servers argument is an array of RFC 5952 formatted
addresses. If the port is the IANA default DNS port (53) it can be omitted.】
dnsPromises.setServers([
'8.8.8.8',
'[2001:4860:4860::8888]',
'8.8.8.8:1053',
'[2001:4860:4860::8888]:1053',
]); 如果提供的地址无效,则会抛出错误。
【An error will be thrown if an invalid address is provided.】
dnsPromises.setServers() 方法在 DNS 查询进行时不得调用。
【The dnsPromises.setServers() method must not be called while a DNS query is in
progress.】
这种方法的工作方式与resolve.conf非常相似。也就是说,如果尝试使用提供的第一个服务器解析时出现NOTFOUND错误,resolve()方法将不会尝试使用随后提供的服务器进行解析。只有在前面的服务器超时或出现其他错误时,才会使用备用DNS服务器。
【This method works much like
resolve.conf.
That is, if attempting to resolve with the first server provided results in a
NOTFOUND error, the resolve() method will not attempt to resolve with
subsequent servers provided. Fallback DNS servers will only be used if the
earlier ones time out or result in some other error.】