@@ -70,33 +70,25 @@ changes:
7070 pr-url: https://github.com/nodejs/node/pull/744
7171 description: The `all` option is supported now.
7272-->
73+ - ` hostname ` {string}
74+ - ` options ` {integer | Object}
75+ - ` family ` {integer} The record family. Must be ` 4 ` or ` 6 ` . IPv4
76+ and IPv6 addresses are both returned by default.
77+ - ` hints ` {number} One or more [ supported ` getaddrinfo ` flags] [ ] . Multiple
78+ flags may be passed by bitwise ` OR ` ing their values.
79+ - ` all ` {boolean} When ` true ` , the callback returns all resolved addresses in
80+ an array. Otherwise, returns a single address. Defaults to ` false ` .
81+ - ` callback ` {Function}
82+ - ` err ` {Error}
83+ - ` address ` {string} A string representation of an IPv4 or IPv6 address.
84+ - ` family ` {integer} ` 4 ` or ` 6 ` , denoting the family of ` address ` .
7385
7486Resolves a hostname (e.g. ` 'nodejs.org' ` ) into the first found A (IPv4) or
75- AAAA (IPv6) record. ` options ` can be an object or integer. If ` options ` is
76- not provided, then IPv4 and IPv6 addresses are both valid. If ` options ` is
77- an integer, then it must be ` 4 ` or ` 6 ` .
78-
79- Alternatively, ` options ` can be an object containing these properties:
80-
81- * ` family ` {number} - The record family. If present, must be the integer
82- ` 4 ` or ` 6 ` . If not provided, both IP v4 and v6 addresses are accepted.
83- * ` hints ` : {number} - If present, it should be one or more of the supported
84- ` getaddrinfo ` flags. If ` hints ` is not provided, then no flags are passed to
85- ` getaddrinfo ` . Multiple flags can be passed through ` hints ` by bitwise
86- ` OR ` ing their values.
87- See [ supported ` getaddrinfo ` flags] [ ] for more information on supported
88- flags.
89- * ` all ` : {boolean} - When ` true ` , the callback returns all resolved addresses
90- in an array, otherwise returns a single address. Defaults to ` false ` .
91-
92- All properties are optional.
93-
94- The ` callback ` function has arguments ` (err, address, family) ` . ` address ` is a
95- string representation of an IPv4 or IPv6 address. ` family ` is either the
96- integer ` 4 ` or ` 6 ` and denotes the family of ` address ` (not necessarily the
97- value initially passed to ` lookup ` ).
98-
99- With the ` all ` option set to ` true ` , the arguments change to
87+ AAAA (IPv6) record. All ` option ` properties are optional. If ` options ` is an
88+ integer, then it must be ` 4 ` or ` 6 ` – if ` options ` is not provided, then IPv4
89+ and IPv6 addresses are both returned if found.
90+
91+ With the ` all ` option set to ` true ` , the arguments for ` callback ` change to
10092` (err, addresses) ` , with ` addresses ` being an array of objects with the
10193properties ` address ` and ` family ` .
10294
@@ -147,6 +139,12 @@ on some operating systems (e.g FreeBSD 10.1).
147139<!-- YAML
148140added: v0.11.14
149141-->
142+ - ` address ` {string}
143+ - ` port ` {number}
144+ - ` callback ` {Function}
145+ - ` err ` {Error}
146+ - ` hostname ` {string} e.g. ` example.com `
147+ - ` service ` {string} e.g. ` http `
150148
151149Resolves the given ` address ` and ` port ` into a hostname and service using
152150the operating system's underlying ` getnameinfo ` implementation.
@@ -155,10 +153,7 @@ If `address` is not a valid IP address, a `TypeError` will be thrown.
155153The ` port ` will be coerced to a number. If it is not a legal port, a ` TypeError `
156154will be thrown.
157155
158- The callback has arguments ` (err, hostname, service) ` . The ` hostname ` and
159- ` service ` arguments are strings (e.g. ` 'localhost' ` and ` 'http' ` respectively).
160-
161- On error, ` err ` is an [ ` Error ` ] [ ] object, where ` err.code ` is the error code.
156+ On an error, ` err ` is an [ ` Error ` ] [ ] object, where ` err.code ` is the error code.
162157
163158``` js
164159const dns = require (' dns' );
@@ -172,6 +167,11 @@ dns.lookupService('127.0.0.1', 22, (err, hostname, service) => {
172167<!-- YAML
173168added: v0.1.27
174169-->
170+ - ` hostname ` {string}
171+ - ` rrtype ` {string}
172+ - ` callback ` {Function}
173+ - ` err ` {Error}
174+ - ` addresses ` {string[ ] | Object[ ] | string[ ] [ ] | Object}
175175
176176Uses the DNS protocol to resolve a hostname (e.g. ` 'nodejs.org' ` ) into an
177177array of the record types specified by ` rrtype ` .
@@ -208,18 +208,21 @@ changes:
208208 description: This method now supports passing `options`,
209209 specifically `options.ttl`.
210210-->
211+ - ` hostname ` {string} Hostname to resolve.
212+ - ` options ` {Object}
213+ - ` ttl ` {boolean} Retrieve the Time-To-Live value (TTL) of each record.
214+ When ` true ` , the callback receives an array of
215+ ` { address: '1.2.3.4', ttl: 60 } ` objects rather than an array of strings,
216+ with the TTL expressed in seconds.
217+ - ` callback ` {Function}
218+ - ` err ` {Error}
219+ - ` addresses ` {string[ ] | Object[ ] }
211220
212221Uses the DNS protocol to resolve a IPv4 addresses (` A ` records) for the
213222` hostname ` . The ` addresses ` argument passed to the ` callback ` function
214223will contain an array of IPv4 addresses (e.g.
215224` ['74.125.79.104', '74.125.79.105', '74.125.79.106'] ` ).
216225
217- * ` hostname ` {string} Hostname to resolve.
218- * ` options ` {Object}
219- * ` ttl ` {boolean} Retrieve the Time-To-Live value (TTL) of each record.
220- The callback receives an array of ` { address: '1.2.3.4', ttl: 60 } ` objects
221- rather than an array of strings. The TTL is expressed in seconds.
222- * ` callback ` {Function} An ` (err, result) ` callback function.
223226
224227## dns.resolve6(hostname[ , options] , callback)
225228<!-- YAML
@@ -230,22 +233,29 @@ changes:
230233 description: This method now supports passing `options`,
231234 specifically `options.ttl`.
232235-->
236+ - ` hostname ` {string} Hostname to resolve.
237+ - ` options ` {Object}
238+ - ` ttl ` {boolean} Retrieve the Time-To-Live value (TTL) of each record.
239+ When ` true ` , the callback receives an array of
240+ ` { address: '0:1:2:3:4:5:6:7', ttl: 60 } ` objects rather than an array of
241+ strings, with the TTL expressed in seconds.
242+ - ` callback ` {Function}
243+ - ` err ` {Error}
244+ - ` addresses ` {string[ ] | Object[ ] }
233245
234246Uses the DNS protocol to resolve a IPv6 addresses (` AAAA ` records) for the
235247` hostname ` . The ` addresses ` argument passed to the ` callback ` function
236248will contain an array of IPv6 addresses.
237249
238- * ` hostname ` {string} Hostname to resolve.
239- * ` options ` {Object}
240- * ` ttl ` {boolean} Retrieve the Time-To-Live value (TTL) of each record.
241- The callback receives an array of ` { address: '0:1:2:3:4:5:6:7', ttl: 60 } `
242- objects rather than an array of strings. The TTL is expressed in seconds.
243- * ` callback ` {Function} An ` (err, result) ` callback function.
244250
245251## dns.resolveCname(hostname, callback)
246252<!-- YAML
247253added: v0.3.2
248254-->
255+ - ` hostname ` {string}
256+ - ` callback ` {Function}
257+ - ` err ` {Error}
258+ - ` addresses ` {string[ ] }
249259
250260Uses the DNS protocol to resolve ` CNAME ` records for the ` hostname ` . The
251261` addresses ` argument passed to the ` callback ` function
@@ -256,6 +266,10 @@ will contain an array of canonical name records available for the `hostname`
256266<!-- YAML
257267added: v0.1.27
258268-->
269+ - ` hostname ` {string}
270+ - ` callback ` {Function}
271+ - ` err ` {Error}
272+ - ` addresses ` {Object[ ] }
259273
260274Uses the DNS protocol to resolve mail exchange records (` MX ` records) for the
261275` hostname ` . The ` addresses ` argument passed to the ` callback ` function will
@@ -266,11 +280,14 @@ property (e.g. `[{priority: 10, exchange: 'mx.example.com'}, ...]`).
266280<!-- YAML
267281added: v0.9.12
268282-->
283+ - ` hostname ` {string}
284+ - ` callback ` {Function}
285+ - ` err ` {Error}
286+ - ` addresses ` {Object[ ] }
269287
270288Uses the DNS protocol to resolve regular expression based records (` NAPTR `
271- records) for the ` hostname ` . The ` callback ` function has arguments
272- ` (err, addresses) ` . The ` addresses ` argument passed to the ` callback ` function
273- will contain an array of objects with the following properties:
289+ records) for the ` hostname ` . The ` addresses ` argument passed to the ` callback `
290+ function will contain an array of objects with the following properties:
274291
275292* ` flags `
276293* ` service `
@@ -296,16 +313,24 @@ For example:
296313<!-- YAML
297314added: v0.1.90
298315-->
316+ - ` hostname ` {string}
317+ - ` callback ` {Function}
318+ - ` err ` {Error}
319+ - ` addresses ` {string[ ] }
299320
300321Uses the DNS protocol to resolve name server records (` NS ` records) for the
301322` hostname ` . The ` addresses ` argument passed to the ` callback ` function will
302323contain an array of name server records available for ` hostname `
303324(e.g. ` ['ns1.example.com', 'ns2.example.com'] ` ).
304325
305- ## dns.resolvePtr(hostname, callback )
326+ ## dns.resolvePtr(hostname)
306327<!-- YAML
307328added: v6.0.0
308329-->
330+ - ` hostname ` {string}
331+ - ` callback ` {Function}
332+ - ` err ` {Error}
333+ - ` addresses ` {string[ ] }
309334
310335Uses the DNS protocol to resolve pointer records (` PTR ` records) for the
311336` hostname ` . The ` addresses ` argument passed to the ` callback ` function will
@@ -315,9 +340,13 @@ be an array of strings containing the reply records.
315340<!-- YAML
316341added: v0.11.10
317342-->
343+ - ` hostname ` {string}
344+ - ` callback ` {Function}
345+ - ` err ` {Error}
346+ - ` address ` {Object}
318347
319348Uses the DNS protocol to resolve a start of authority record (` SOA ` record) for
320- the ` hostname ` . The ` addresses ` argument passed to the ` callback ` function will
349+ the ` hostname ` . The ` address ` argument passed to the ` callback ` function will
321350be an object with the following properties:
322351
323352* ` nsname `
@@ -344,6 +373,10 @@ be an object with the following properties:
344373<!-- YAML
345374added: v0.1.27
346375-->
376+ - ` hostname ` {string}
377+ - ` callback ` {Function}
378+ - ` err ` {Error}
379+ - ` addresses ` {Object[ ] }
347380
348381Uses the DNS protocol to resolve service records (` SRV ` records) for the
349382` hostname ` . The ` addresses ` argument passed to the ` callback ` function will
@@ -367,6 +400,10 @@ be an array of objects with the following properties:
367400<!-- YAML
368401added: v0.1.27
369402-->
403+ - ` hostname ` {string}
404+ - ` callback ` {Function}
405+ - ` err ` {Error}
406+ - ` addresses ` {string[ ] [ ] }
370407
371408Uses the DNS protocol to resolve text queries (` TXT ` records) for the
372409` hostname ` . The ` addresses ` argument passed to the ` callback ` function is
@@ -379,25 +416,27 @@ treated separately.
379416<!-- YAML
380417added: v0.1.16
381418-->
419+ - ` ip ` {string}
420+ - ` callback ` {Function}
421+ - ` err ` {Error}
422+ - ` hostnames ` {string[ ] }
382423
383424Performs a reverse DNS query that resolves an IPv4 or IPv6 address to an
384425array of hostnames.
385426
386- The ` callback ` function has arguments ` (err, hostnames) ` , where ` hostnames `
387- is an array of resolved hostnames for the given ` ip ` .
388-
389427On error, ` err ` is an [ ` Error ` ] [ ] object, where ` err.code ` is
390428one of the [ DNS error codes] [ ] .
391429
392430## dns.setServers(servers)
393431<!-- YAML
394432added: v0.11.3
395433-->
434+ - ` servers ` {string[ ] }
396435
397436Sets the IP addresses of the servers to be used when resolving. The ` servers `
398437argument is an array of IPv4 or IPv6 addresses.
399438
400- If a port specified on the address it will be removed.
439+ If a port is specified on the address, it will be removed.
401440
402441An error will be thrown if an invalid address is provided.
403442
0 commit comments