dnsPromises.resolve(hostname[, rrtype])
使用域名系统协议将主机名(例如 'nodejs.org'
)解析为资源记录数组。
当成功时,Promise
使用资源记录数组解决。
个别结果的类型和结构因 rrtype
而异:
rrtype | records 包含 | 结果的类型 | 快捷方法 |
---|---|---|---|
'A' | IPv4 地址(默认) | <string> | dnsPromises.resolve4() |
'AAAA' | IPv6 地址 | <string> | dnsPromises.resolve6() |
'ANY' | 任何记录 | <Object> | dnsPromises.resolveAny() |
'CAA' | CA 授权记录 | <Object> | dnsPromises.resolveCaa() |
'CNAME' | 规范名称记录 | <string> | dnsPromises.resolveCname() |
'MX' | 邮件交换记录 | <Object> | dnsPromises.resolveMx() |
'NAPTR' | 名称授权指针记录 | <Object> | dnsPromises.resolveNaptr() |
'NS' | 名称服务器记录 | <string> | dnsPromises.resolveNs() |
'PTR' | 指针记录 | <string> | dnsPromises.resolvePtr() |
'SOA' | 起始规范记录 | <Object> | dnsPromises.resolveSoa() |
'SRV' | 服务记录 | <Object> | dnsPromises.resolveSrv() |
'TXT' | 文本记录 | <string[]> | dnsPromises.resolveTxt() |
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() |
'TXT' | text records | <string[]> | dnsPromises.resolveTxt() |
On error, the Promise
is rejected with an Error
object, where err.code
is one of the DNS error codes.