@@ -70,33 +70,25 @@ changes:
70
70
pr-url: https://github.com/nodejs/node/pull/744
71
71
description: The `all` option is supported now.
72
72
-->
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 ` .
73
85
74
86
Resolves 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
100
92
` (err, addresses) ` , with ` addresses ` being an array of objects with the
101
93
properties ` address ` and ` family ` .
102
94
@@ -147,6 +139,12 @@ on some operating systems (e.g FreeBSD 10.1).
147
139
<!-- YAML
148
140
added: v0.11.14
149
141
-->
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 `
150
148
151
149
Resolves the given ` address ` and ` port ` into a hostname and service using
152
150
the operating system's underlying ` getnameinfo ` implementation.
@@ -155,10 +153,7 @@ If `address` is not a valid IP address, a `TypeError` will be thrown.
155
153
The ` port ` will be coerced to a number. If it is not a legal port, a ` TypeError `
156
154
will be thrown.
157
155
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.
162
157
163
158
``` js
164
159
const dns = require (' dns' );
@@ -172,6 +167,11 @@ dns.lookupService('127.0.0.1', 22, (err, hostname, service) => {
172
167
<!-- YAML
173
168
added: v0.1.27
174
169
-->
170
+ - ` hostname ` {string}
171
+ - ` rrtype ` {string}
172
+ - ` callback ` {Function}
173
+ - ` err ` {Error}
174
+ - ` addresses ` {string[ ] | Object[ ] | string[ ] [ ] | Object}
175
175
176
176
Uses the DNS protocol to resolve a hostname (e.g. ` 'nodejs.org' ` ) into an
177
177
array of the record types specified by ` rrtype ` .
@@ -208,18 +208,21 @@ changes:
208
208
description: This method now supports passing `options`,
209
209
specifically `options.ttl`.
210
210
-->
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[ ] }
211
220
212
221
Uses the DNS protocol to resolve a IPv4 addresses (` A ` records) for the
213
222
` hostname ` . The ` addresses ` argument passed to the ` callback ` function
214
223
will contain an array of IPv4 addresses (e.g.
215
224
` ['74.125.79.104', '74.125.79.105', '74.125.79.106'] ` ).
216
225
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.
223
226
224
227
## dns.resolve6(hostname[ , options] , callback)
225
228
<!-- YAML
@@ -230,22 +233,29 @@ changes:
230
233
description: This method now supports passing `options`,
231
234
specifically `options.ttl`.
232
235
-->
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[ ] }
233
245
234
246
Uses the DNS protocol to resolve a IPv6 addresses (` AAAA ` records) for the
235
247
` hostname ` . The ` addresses ` argument passed to the ` callback ` function
236
248
will contain an array of IPv6 addresses.
237
249
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.
244
250
245
251
## dns.resolveCname(hostname, callback)
246
252
<!-- YAML
247
253
added: v0.3.2
248
254
-->
255
+ - ` hostname ` {string}
256
+ - ` callback ` {Function}
257
+ - ` err ` {Error}
258
+ - ` addresses ` {string[ ] }
249
259
250
260
Uses the DNS protocol to resolve ` CNAME ` records for the ` hostname ` . The
251
261
` addresses ` argument passed to the ` callback ` function
@@ -256,6 +266,10 @@ will contain an array of canonical name records available for the `hostname`
256
266
<!-- YAML
257
267
added: v0.1.27
258
268
-->
269
+ - ` hostname ` {string}
270
+ - ` callback ` {Function}
271
+ - ` err ` {Error}
272
+ - ` addresses ` {Object[ ] }
259
273
260
274
Uses the DNS protocol to resolve mail exchange records (` MX ` records) for the
261
275
` hostname ` . The ` addresses ` argument passed to the ` callback ` function will
@@ -266,11 +280,14 @@ property (e.g. `[{priority: 10, exchange: 'mx.example.com'}, ...]`).
266
280
<!-- YAML
267
281
added: v0.9.12
268
282
-->
283
+ - ` hostname ` {string}
284
+ - ` callback ` {Function}
285
+ - ` err ` {Error}
286
+ - ` addresses ` {Object[ ] }
269
287
270
288
Uses 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:
274
291
275
292
* ` flags `
276
293
* ` service `
@@ -296,16 +313,24 @@ For example:
296
313
<!-- YAML
297
314
added: v0.1.90
298
315
-->
316
+ - ` hostname ` {string}
317
+ - ` callback ` {Function}
318
+ - ` err ` {Error}
319
+ - ` addresses ` {string[ ] }
299
320
300
321
Uses the DNS protocol to resolve name server records (` NS ` records) for the
301
322
` hostname ` . The ` addresses ` argument passed to the ` callback ` function will
302
323
contain an array of name server records available for ` hostname `
303
324
(e.g. ` ['ns1.example.com', 'ns2.example.com'] ` ).
304
325
305
- ## dns.resolvePtr(hostname, callback )
326
+ ## dns.resolvePtr(hostname)
306
327
<!-- YAML
307
328
added: v6.0.0
308
329
-->
330
+ - ` hostname ` {string}
331
+ - ` callback ` {Function}
332
+ - ` err ` {Error}
333
+ - ` addresses ` {string[ ] }
309
334
310
335
Uses the DNS protocol to resolve pointer records (` PTR ` records) for the
311
336
` hostname ` . The ` addresses ` argument passed to the ` callback ` function will
@@ -315,9 +340,13 @@ be an array of strings containing the reply records.
315
340
<!-- YAML
316
341
added: v0.11.10
317
342
-->
343
+ - ` hostname ` {string}
344
+ - ` callback ` {Function}
345
+ - ` err ` {Error}
346
+ - ` address ` {Object}
318
347
319
348
Uses 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
321
350
be an object with the following properties:
322
351
323
352
* ` nsname `
@@ -344,6 +373,10 @@ be an object with the following properties:
344
373
<!-- YAML
345
374
added: v0.1.27
346
375
-->
376
+ - ` hostname ` {string}
377
+ - ` callback ` {Function}
378
+ - ` err ` {Error}
379
+ - ` addresses ` {Object[ ] }
347
380
348
381
Uses the DNS protocol to resolve service records (` SRV ` records) for the
349
382
` hostname ` . The ` addresses ` argument passed to the ` callback ` function will
@@ -367,6 +400,10 @@ be an array of objects with the following properties:
367
400
<!-- YAML
368
401
added: v0.1.27
369
402
-->
403
+ - ` hostname ` {string}
404
+ - ` callback ` {Function}
405
+ - ` err ` {Error}
406
+ - ` addresses ` {string[ ] [ ] }
370
407
371
408
Uses the DNS protocol to resolve text queries (` TXT ` records) for the
372
409
` hostname ` . The ` addresses ` argument passed to the ` callback ` function is
@@ -379,25 +416,27 @@ treated separately.
379
416
<!-- YAML
380
417
added: v0.1.16
381
418
-->
419
+ - ` ip ` {string}
420
+ - ` callback ` {Function}
421
+ - ` err ` {Error}
422
+ - ` hostnames ` {string[ ] }
382
423
383
424
Performs a reverse DNS query that resolves an IPv4 or IPv6 address to an
384
425
array of hostnames.
385
426
386
- The ` callback ` function has arguments ` (err, hostnames) ` , where ` hostnames `
387
- is an array of resolved hostnames for the given ` ip ` .
388
-
389
427
On error, ` err ` is an [ ` Error ` ] [ ] object, where ` err.code ` is
390
428
one of the [ DNS error codes] [ ] .
391
429
392
430
## dns.setServers(servers)
393
431
<!-- YAML
394
432
added: v0.11.3
395
433
-->
434
+ - ` servers ` {string[ ] }
396
435
397
436
Sets the IP addresses of the servers to be used when resolving. The ` servers `
398
437
argument is an array of IPv4 or IPv6 addresses.
399
438
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.
401
440
402
441
An error will be thrown if an invalid address is provided.
403
442
0 commit comments