Browse Source

doc: clarify the callback arguments of dns.resolve

PR-URL: https://github.com/nodejs/node/pull/9532
Backport-PR-URL: https://github.com/nodejs/node/pull/13073
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
v6.x
Roman Reiss 8 years ago
committed by Myles Borins
parent
commit
5b379e0aad
No known key found for this signature in database GPG Key ID: 933B01F40B5CA946
  1. 60
      doc/api/dns.md

60
doc/api/dns.md

@ -169,31 +169,32 @@ dns.lookupService('127.0.0.1', 22, (err, hostname, service) => {
added: v0.1.27 added: v0.1.27
--> -->
Uses the DNS protocol to resolve a hostname (e.g. `'nodejs.org'`) into an - `hostname` {string} Hostname to resolve.
array of the record types specified by `rrtype`. - `rrtype` {string} Resource record type. Default: `'A'`.
- `callback` {Function}
Valid values for `rrtype` are: - `err` {Error}
- `records` {string[] | Object[] | string[][] | Object}
* `'A'` - IPV4 addresses, default
* `'AAAA'` - IPV6 addresses Uses the DNS protocol to resolve a hostname (e.g. `'nodejs.org'`) into an array
* `'MX'` - mail exchange records of the resource records. The `callback` function has arguments
* `'TXT'` - text records `(err, records)`. When successful, `records` will be an array of resource
* `'SRV'` - SRV records records. The type and structure of individual results varies based on `rrtype`:
* `'PTR'` - PTR records
* `'NS'` - name server records | `rrtype` | `records` contains | Result type | Shorthand method |
* `'CNAME'` - canonical name records |-----------|--------------------------------|-------------|--------------------------|
* `'SOA'` - start of authority record | `'A'` | IPv4 addresses (default) | {string} | [`dns.resolve4()`][] |
* `'NAPTR'` - name authority pointer record | `'AAAA'` | IPv6 addresses | {string} | [`dns.resolve6()`][] |
| `'CNAME'` | canonical name records | {string} | [`dns.resolveCname()`][] |
The `callback` function has arguments `(err, addresses)`. When successful, | `'MX'` | mail exchange records | {Object} | [`dns.resolveMx()`][] |
`addresses` will be an array, except when resolving an SOA record which returns | `'NAPTR'` | name authority pointer records | {Object} | [`dns.resolveNaptr()`][] |
an object structured in the same manner as one returned by the | `'NS'` | name server records | {string} | [`dns.resolveNs()`][] |
[`dns.resolveSoa()`][] method. The type of each item in `addresses` is | `'PTR'` | pointer records | {string} | [`dns.resolvePtr()`][] |
determined by the record type, and described in the documentation for the | `'SOA'` | start of authority records | {Object} | [`dns.resolveSoa()`][] |
corresponding lookup methods. | `'SRV'` | service records | {Object} | [`dns.resolveSrv()`][] |
| `'TXT'` | text records | {string} | [`dns.resolveTxt()`][] |
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) ## dns.resolve4(hostname[, options], callback)
<!-- YAML <!-- YAML
@ -463,7 +464,16 @@ uses. For instance, _they do not use the configuration from `/etc/hosts`_.
[DNS error codes]: #dns_error_codes [DNS error codes]: #dns_error_codes
[`dns.lookup()`]: #dns_dns_lookup_hostname_options_callback [`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.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 [`Error`]: errors.html#errors_class_error
[Implementation considerations section]: #dns_implementation_considerations [Implementation considerations section]: #dns_implementation_considerations
[supported `getaddrinfo` flags]: #dns_supported_getaddrinfo_flags [supported `getaddrinfo` flags]: #dns_supported_getaddrinfo_flags

Loading…
Cancel
Save