dnsPromises.resolve(hostname[, rrtype])
使用 DNS 协议将主机名(例如 'nodejs.org')解析为资源记录数组。成功时,Promise 会解析为一个资源记录数组。单个结果的类型和结构取决于 rrtype:
【Uses the DNS protocol to resolve a host name (e.g. 'nodejs.org') into an array
of the resource records. When successful, the Promise is resolved with an
array of resource records. The type and structure of individual results vary
based on rrtype:】
rrtype | records contains | Result type | Shorthand method |
|---|---|---|---|
'A' | IPv4 addresses (default) | <string> | dnsPromises.resolve4() |
'AAAA' | IPv6 addresses | <string> | dnsPromises.resolve6() |
'ANY' | any records | <Object> | dnsPromises.resolveAny() |
'CAA' | CA authorization records | <Object> | dnsPromises.resolveCaa() |
'CNAME' | canonical name records | <string> | dnsPromises.resolveCname() |
'MX' | mail exchange records | <Object> | dnsPromises.resolveMx() |
'NAPTR' | name authority pointer records | <Object> | dnsPromises.resolveNaptr() |
'NS' | name server records | <string> | dnsPromises.resolveNs() |
'PTR' | pointer records | <string> | dnsPromises.resolvePtr() |
'SOA' | start of authority records | <Object> | dnsPromises.resolveSoa() |
'SRV' | service records | <Object> | dnsPromises.resolveSrv() |
'TLSA' | certificate associations | <Object> | dnsPromises.resolveTlsa() |
'TXT' | text records | <string[]> | dnsPromises.resolveTxt() |
在发生错误时,Promise 会被 Error 对象拒绝,其中 err.code 是 DNS 错误代码 之一。
【On error, the Promise is rejected with an Error object, where err.code
is one of the DNS error codes.】