Skip to content

Commit

Permalink
doc: clarify dns.resolve API
Browse files Browse the repository at this point in the history
  • Loading branch information
silverwind committed Apr 12, 2017
1 parent ec53921 commit f690863
Showing 1 changed file with 26 additions and 21 deletions.
47 changes: 26 additions & 21 deletions doc/api/dns.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,30 +174,26 @@ added: v0.1.27
- `addresses` {string[] | Object[] | string[][] | Object}

Uses the DNS protocol to resolve a hostname (e.g. `'nodejs.org'`) into an
array of the record types specified by `rrtype`.

Valid values for `rrtype` are:

* `'A'` - IPV4 addresses, default
* `'AAAA'` - IPV6 addresses
* `'MX'` - mail exchange records
* `'TXT'` - text records
* `'SRV'` - SRV records
* `'PTR'` - PTR records
* `'NS'` - name server records
* `'CNAME'` - canonical name records
* `'SOA'` - start of authority record
* `'NAPTR'` - name authority pointer record
array of the resource records, specified by `rrtype` (resource record type):

| `rrtype` | Return array contains | Result type | Shorthand method |
|-----------|--------------------------------|-------------|--------------------------|
| `'A'` | IPv4 addresses (default) | {String} | [`dns.resolve4()`][] |
| `'AAAA'` | IPv6 addresses | {String} | [`dns.resolve6()`][] |
| `'CNAME'` | canonical name records | {String} | [`dns.resolveCname()`][] |
| `'MX'` | mail exchange records | {Object} | [`dns.resolveMx()`][] |
| `'NAPTR'` | name authority pointer records | {Object} | [`dns.resolveNaptr()`][] |
| `'NS'` | name server records | {String} | [`dns.resolveNs()`][] |
| `'PTR'` | pointer records | {String} | [`dns.resolvePtr()`][] |
| `'SOA'` | start of authority records | {Object} | [`dns.resolveSoa()`][] |
| `'SRV'` | service records | {Object} | [`dns.resolveSrv()`][] |
| `'TXT'` | text records | {String} | [`dns.resolveTxt()`][] |

The `callback` function has arguments `(err, addresses)`. When successful,
`addresses` will be an array, except when resolving an SOA record which returns
an object structured in the same manner as one returned by the
[`dns.resolveSoa()`][] method. The type of each item in `addresses` is
determined by the record type, and described in the documentation for the
corresponding lookup methods.
`addresses` will be an array of results.

On error, `err` is an [`Error`][] object, where `err.code` is
one of the error codes listed [here](#dns_error_codes).
On error, `err` is an [`Error`][] object, where `err.code` is one of the
[DNS error codes](#dns_error_codes).

## dns.resolve4(hostname[, options], callback)
<!-- YAML
Expand Down Expand Up @@ -516,7 +512,16 @@ uses. For instance, _they do not use the configuration from `/etc/hosts`_.

[DNS error codes]: #dns_error_codes
[`dns.lookup()`]: #dns_dns_lookup_hostname_options_callback
[`dns.resolve4()`]: #dns_dns_resolve4_hostname_options_callback
[`dns.resolve6()`]: #dns_dns_resolve6_hostname_options_callback
[`dns.resolveCname()`]: #dns_dns_resolvecname_hostname_callback
[`dns.resolveMx()`]: #dns_dns_resolvemx_hostname_callback
[`dns.resolveNaptr()`]: #dns_dns_resolvenaptr_hostname_callback
[`dns.resolveNs()`]: #dns_dns_resolvens_hostname_callback
[`dns.resolvePtr()`]: #dns_dns_resolveptr_hostname_callback
[`dns.resolveSoa()`]: #dns_dns_resolvesoa_hostname_callback
[`dns.resolveSrv()`]: #dns_dns_resolvesrv_hostname_callback
[`dns.resolveTxt()`]: #dns_dns_resolvetxt_hostname_callback
[`Error`]: errors.html#errors_class_error
[Implementation considerations section]: #dns_implementation_considerations
[supported `getaddrinfo` flags]: #dns_supported_getaddrinfo_flags
Expand Down

0 comments on commit f690863

Please sign in to comment.