From f6908638cceda878db01429cbe00186ddc854622 Mon Sep 17 00:00:00 2001 From: Roman Reiss Date: Fri, 9 Dec 2016 20:17:53 +0100 Subject: [PATCH 1/6] doc: clarify dns.resolve API --- doc/api/dns.md | 47 ++++++++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/doc/api/dns.md b/doc/api/dns.md index 329ff0c3ae028a..8e879f0a4f3c80 100644 --- a/doc/api/dns.md +++ b/doc/api/dns.md @@ -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) -- `hostname` {string} -- `rrtype` {string} +- `hostname` {string} Hostname to resolve. +- `rrtype` {string} Resource record type. Default: `'A'`. - `callback` {Function} - `err` {Error} - - `addresses` {string[] | Object[] | string[][] | Object} + - `records` {string[] | Object[] | string[][] | Object} -Uses the DNS protocol to resolve a hostname (e.g. `'nodejs.org'`) into an -array of the resource records, specified by `rrtype` (resource record type): +Uses the DNS protocol to resolve a hostname (e.g. `'nodejs.org'`) into an array +of the resource records. The `callback` function has arguments +`(err, records)`. When successful, `records` will be an array of resource +records. The type and structure of individual results varies based on `rrtype`: -| `rrtype` | Return {Array} contains | Result type | Shorthand method | +| `rrtype` | `records` contains | Result type | Shorthand method | |-----------|--------------------------------|-------------|--------------------------| | `'A'` | IPv4 addresses (default) | {string} | [`dns.resolve4()`][] | | `'AAAA'` | IPv6 addresses | {string} | [`dns.resolve6()`][] | @@ -189,9 +191,6 @@ array of the resource records, specified by `rrtype` (resource record type): | `'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 of results. - On error, `err` is an [`Error`][] object, where `err.code` is one of the [DNS error codes](#dns_error_codes).