dns.resolveAny(hostname, callback)


使用域名系统协议解析所有记录(也称为 ANY* 查询)。传给 callback 函数的 ret 参数将是包含各种类型记录的数组。每个对象都有表示当前记录的类型的属性 type。并且根据 type,对象上将出现其他属性:

¥Uses the DNS protocol to resolve all records (also known as ANY or * query). The ret argument passed to the callback function will be an array containing various types of records. Each object has a property type that indicates the type of the current record. And depending on the type, additional properties will be present on the object:

类型属性
'A'address/ttl
'AAAA'address/ttl
'CNAME'value
'MX'参考 dns.resolveMx()
'NAPTR'参考 dns.resolveNaptr()
'NS'value
'PTR'value
'SOA'参考 dns.resolveSoa()
'SRV'参考 dns.resolveSrv()
'TLSA'参考 dns.resolveTlsa()
'TXT'这种类型的记录包含一个名为 entries 的数组属性,它引用 dns.resolveTxt(),例如 { entries: ['...'], type: 'TXT' }

这是传给回调的 ret 对象的示例:

¥Here is an example of the ret object passed to the callback:

[ { type: 'A', address: '127.0.0.1', ttl: 299 },
  { type: 'CNAME', value: 'example.com' },
  { type: 'MX', exchange: 'alt4.aspmx.l.example.com', priority: 50 },
  { type: 'NS', value: 'ns1.example.com' },
  { type: 'TXT', entries: [ 'v=spf1 include:_spf.example.com ~all' ] },
  { type: 'SOA',
    nsname: 'ns1.example.com',
    hostmaster: 'admin.example.com',
    serial: 156696742,
    refresh: 900,
    retry: 900,
    expire: 1800,
    minttl: 60 } ] 

域名系统服务器服务商可以选择不响应 ANY 查询。调用单个方法(如 dns.resolve4()dns.resolveMx() 等)可能会更好。更多详细信息,请参见 RFC 8482

¥DNS server operators may choose not to respond to ANY queries. It may be better to call individual methods like dns.resolve4(), dns.resolveMx(), and so on. For more details, see RFC 8482.