@types/node 16.3.3 → 16.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
node/dns.d.ts CHANGED
@@ -1,6 +1,51 @@
1
+ /**
2
+ * The `dns` module enables name resolution. For example, use it to look up IP
3
+ * addresses of host names.
4
+ *
5
+ * Although named for the [Domain Name System (DNS)](https://en.wikipedia.org/wiki/Domain_Name_System), it does not always use the
6
+ * DNS protocol for lookups. {@link lookup} uses the operating system
7
+ * facilities to perform name resolution. It may not need to perform any network
8
+ * communication. To perform name resolution the way other applications on the same
9
+ * system do, use {@link lookup}.
10
+ *
11
+ * ```js
12
+ * const dns = require('dns');
13
+ *
14
+ * dns.lookup('example.org', (err, address, family) => {
15
+ * console.log('address: %j family: IPv%s', address, family);
16
+ * });
17
+ * // address: "93.184.216.34" family: IPv4
18
+ * ```
19
+ *
20
+ * All other functions in the `dns` module connect to an actual DNS server to
21
+ * perform name resolution. They will always use the network to perform DNS
22
+ * queries. These functions do not use the same set of configuration files used by {@link lookup} (e.g. `/etc/hosts`). Use these functions to always perform
23
+ * DNS queries, bypassing other name-resolution facilities.
24
+ *
25
+ * ```js
26
+ * const dns = require('dns');
27
+ *
28
+ * dns.resolve4('archive.org', (err, addresses) => {
29
+ * if (err) throw err;
30
+ *
31
+ * console.log(`addresses: ${JSON.stringify(addresses)}`);
32
+ *
33
+ * addresses.forEach((a) => {
34
+ * dns.reverse(a, (err, hostnames) => {
35
+ * if (err) {
36
+ * throw err;
37
+ * }
38
+ * console.log(`reverse for ${a}: ${JSON.stringify(hostnames)}`);
39
+ * });
40
+ * });
41
+ * });
42
+ * ```
43
+ *
44
+ * See the `Implementation considerations section` for more information.
45
+ * @see [source](https://github.com/nodejs/node/blob/v16.4.2/lib/dns.js)
46
+ */
1
47
  declare module 'dns' {
2
- import * as dnsPromises from "node:dns/promises";
3
-
48
+ import * as dnsPromises from 'node:dns/promises';
4
49
  // Supported getaddrinfo flags.
5
50
  export const ADDRCONFIG: number;
6
51
  export const V4MAPPED: number;
@@ -9,70 +54,122 @@ declare module 'dns' {
9
54
  * well as IPv4 mapped IPv6 addresses.
10
55
  */
11
56
  export const ALL: number;
12
-
13
57
  export interface LookupOptions {
14
58
  family?: number | undefined;
15
59
  hints?: number | undefined;
16
60
  all?: boolean | undefined;
17
61
  verbatim?: boolean | undefined;
18
62
  }
19
-
20
63
  export interface LookupOneOptions extends LookupOptions {
21
64
  all?: false | undefined;
22
65
  }
23
-
24
66
  export interface LookupAllOptions extends LookupOptions {
25
67
  all: true;
26
68
  }
27
-
28
69
  export interface LookupAddress {
29
70
  address: string;
30
71
  family: number;
31
72
  }
32
-
73
+ /**
74
+ * Resolves a host name (e.g. `'nodejs.org'`) into the first found A (IPv4) or
75
+ * AAAA (IPv6) record. All `option` properties are optional. If `options` is an
76
+ * integer, then it must be `4` or `6` – if `options` is not provided, then IPv4
77
+ * and IPv6 addresses are both returned if found.
78
+ *
79
+ * With the `all` option set to `true`, the arguments for `callback` change to`(err, addresses)`, with `addresses` being an array of objects with the
80
+ * properties `address` and `family`.
81
+ *
82
+ * On error, `err` is an `Error` object, where `err.code` is the error code.
83
+ * Keep in mind that `err.code` will be set to `'ENOTFOUND'` not only when
84
+ * the host name does not exist but also when the lookup fails in other ways
85
+ * such as no available file descriptors.
86
+ *
87
+ * `dns.lookup()` does not necessarily have anything to do with the DNS protocol.
88
+ * The implementation uses an operating system facility that can associate names
89
+ * with addresses, and vice versa. This implementation can have subtle but
90
+ * important consequences on the behavior of any Node.js program. Please take some
91
+ * time to consult the `Implementation considerations section` before using`dns.lookup()`.
92
+ *
93
+ * Example usage:
94
+ *
95
+ * ```js
96
+ * const dns = require('dns');
97
+ * const options = {
98
+ * family: 6,
99
+ * hints: dns.ADDRCONFIG | dns.V4MAPPED,
100
+ * };
101
+ * dns.lookup('example.com', options, (err, address, family) =>
102
+ * console.log('address: %j family: IPv%s', address, family));
103
+ * // address: "2606:2800:220:1:248:1893:25c8:1946" family: IPv6
104
+ *
105
+ * // When options.all is true, the result will be an Array.
106
+ * options.all = true;
107
+ * dns.lookup('example.com', options, (err, addresses) =>
108
+ * console.log('addresses: %j', addresses));
109
+ * // addresses: [{"address":"2606:2800:220:1:248:1893:25c8:1946","family":6}]
110
+ * ```
111
+ *
112
+ * If this method is invoked as its `util.promisify()` ed version, and `all`is not set to `true`, it returns a `Promise` for an `Object` with `address` and`family` properties.
113
+ * @since v0.1.90
114
+ */
33
115
  export function lookup(hostname: string, family: number, callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void): void;
34
116
  export function lookup(hostname: string, options: LookupOneOptions, callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void): void;
35
117
  export function lookup(hostname: string, options: LookupAllOptions, callback: (err: NodeJS.ErrnoException | null, addresses: LookupAddress[]) => void): void;
36
118
  export function lookup(hostname: string, options: LookupOptions, callback: (err: NodeJS.ErrnoException | null, address: string | LookupAddress[], family: number) => void): void;
37
119
  export function lookup(hostname: string, callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void): void;
38
-
39
- // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
40
120
  export namespace lookup {
41
121
  function __promisify__(hostname: string, options: LookupAllOptions): Promise<LookupAddress[]>;
42
122
  function __promisify__(hostname: string, options?: LookupOneOptions | number): Promise<LookupAddress>;
43
123
  function __promisify__(hostname: string, options: LookupOptions): Promise<LookupAddress | LookupAddress[]>;
44
124
  }
45
-
125
+ /**
126
+ * Resolves the given `address` and `port` into a host name and service using
127
+ * the operating system's underlying `getnameinfo` implementation.
128
+ *
129
+ * If `address` is not a valid IP address, a `TypeError` will be thrown.
130
+ * The `port` will be coerced to a number. If it is not a legal port, a `TypeError`will be thrown.
131
+ *
132
+ * On an error, `err` is an `Error` object, where `err.code` is the error code.
133
+ *
134
+ * ```js
135
+ * const dns = require('dns');
136
+ * dns.lookupService('127.0.0.1', 22, (err, hostname, service) => {
137
+ * console.log(hostname, service);
138
+ * // Prints: localhost ssh
139
+ * });
140
+ * ```
141
+ *
142
+ * If this method is invoked as its `util.promisify()` ed version, it returns a`Promise` for an `Object` with `hostname` and `service` properties.
143
+ * @since v0.11.14
144
+ */
46
145
  export function lookupService(address: string, port: number, callback: (err: NodeJS.ErrnoException | null, hostname: string, service: string) => void): void;
47
-
48
146
  export namespace lookupService {
49
- function __promisify__(address: string, port: number): Promise<{ hostname: string, service: string }>;
147
+ function __promisify__(
148
+ address: string,
149
+ port: number
150
+ ): Promise<{
151
+ hostname: string;
152
+ service: string;
153
+ }>;
50
154
  }
51
-
52
155
  export interface ResolveOptions {
53
156
  ttl: boolean;
54
157
  }
55
-
56
158
  export interface ResolveWithTtlOptions extends ResolveOptions {
57
159
  ttl: true;
58
160
  }
59
-
60
161
  export interface RecordWithTtl {
61
162
  address: string;
62
163
  ttl: number;
63
164
  }
64
-
65
165
  /** @deprecated Use `AnyARecord` or `AnyAaaaRecord` instead. */
66
166
  export type AnyRecordWithTtl = AnyARecord | AnyAaaaRecord;
67
-
68
167
  export interface AnyARecord extends RecordWithTtl {
69
- type: "A";
168
+ type: 'A';
70
169
  }
71
-
72
170
  export interface AnyAaaaRecord extends RecordWithTtl {
73
- type: "AAAA";
171
+ type: 'AAAA';
74
172
  }
75
-
76
173
  export interface CaaRecord {
77
174
  critial: number;
78
175
  issue?: string | undefined;
@@ -81,16 +178,13 @@ declare module 'dns' {
81
178
  contactemail?: string | undefined;
82
179
  contactphone?: string | undefined;
83
180
  }
84
-
85
181
  export interface MxRecord {
86
182
  priority: number;
87
183
  exchange: string;
88
184
  }
89
-
90
185
  export interface AnyMxRecord extends MxRecord {
91
- type: "MX";
186
+ type: 'MX';
92
187
  }
93
-
94
188
  export interface NaptrRecord {
95
189
  flags: string;
96
190
  service: string;
@@ -99,11 +193,9 @@ declare module 'dns' {
99
193
  order: number;
100
194
  preference: number;
101
195
  }
102
-
103
196
  export interface AnyNaptrRecord extends NaptrRecord {
104
- type: "NAPTR";
197
+ type: 'NAPTR';
105
198
  }
106
-
107
199
  export interface SoaRecord {
108
200
  nsname: string;
109
201
  hostmaster: string;
@@ -113,159 +205,327 @@ declare module 'dns' {
113
205
  expire: number;
114
206
  minttl: number;
115
207
  }
116
-
117
208
  export interface AnySoaRecord extends SoaRecord {
118
- type: "SOA";
209
+ type: 'SOA';
119
210
  }
120
-
121
211
  export interface SrvRecord {
122
212
  priority: number;
123
213
  weight: number;
124
214
  port: number;
125
215
  name: string;
126
216
  }
127
-
128
217
  export interface AnySrvRecord extends SrvRecord {
129
- type: "SRV";
218
+ type: 'SRV';
130
219
  }
131
-
132
220
  export interface AnyTxtRecord {
133
- type: "TXT";
221
+ type: 'TXT';
134
222
  entries: string[];
135
223
  }
136
-
137
224
  export interface AnyNsRecord {
138
- type: "NS";
225
+ type: 'NS';
139
226
  value: string;
140
227
  }
141
-
142
228
  export interface AnyPtrRecord {
143
- type: "PTR";
229
+ type: 'PTR';
144
230
  value: string;
145
231
  }
146
-
147
232
  export interface AnyCnameRecord {
148
- type: "CNAME";
233
+ type: 'CNAME';
149
234
  value: string;
150
235
  }
151
-
152
- export type AnyRecord = AnyARecord |
153
- AnyAaaaRecord |
154
- AnyCnameRecord |
155
- AnyMxRecord |
156
- AnyNaptrRecord |
157
- AnyNsRecord |
158
- AnyPtrRecord |
159
- AnySoaRecord |
160
- AnySrvRecord |
161
- AnyTxtRecord;
162
-
236
+ export type AnyRecord = AnyARecord | AnyAaaaRecord | AnyCnameRecord | AnyMxRecord | AnyNaptrRecord | AnyNsRecord | AnyPtrRecord | AnySoaRecord | AnySrvRecord | AnyTxtRecord;
237
+ /**
238
+ * Uses the DNS protocol to resolve a host name (e.g. `'nodejs.org'`) into an array
239
+ * of the resource records. The `callback` function has arguments`(err, records)`. When successful, `records` will be an array of resource
240
+ * records. The type and structure of individual results varies based on `rrtype`:
241
+ *
242
+ * <omitted>
243
+ *
244
+ * On error, `err` is an `Error` object, where `err.code` is one of the `DNS error codes`.
245
+ * @since v0.1.27
246
+ * @param hostname Host name to resolve.
247
+ * @param rrtype Resource record type.
248
+ */
163
249
  export function resolve(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
164
- export function resolve(hostname: string, rrtype: "A", callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
165
- export function resolve(hostname: string, rrtype: "AAAA", callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
166
- export function resolve(hostname: string, rrtype: "ANY", callback: (err: NodeJS.ErrnoException | null, addresses: AnyRecord[]) => void): void;
167
- export function resolve(hostname: string, rrtype: "CNAME", callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
168
- export function resolve(hostname: string, rrtype: "MX", callback: (err: NodeJS.ErrnoException | null, addresses: MxRecord[]) => void): void;
169
- export function resolve(hostname: string, rrtype: "NAPTR", callback: (err: NodeJS.ErrnoException | null, addresses: NaptrRecord[]) => void): void;
170
- export function resolve(hostname: string, rrtype: "NS", callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
171
- export function resolve(hostname: string, rrtype: "PTR", callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
172
- export function resolve(hostname: string, rrtype: "SOA", callback: (err: NodeJS.ErrnoException | null, addresses: SoaRecord) => void): void;
173
- export function resolve(hostname: string, rrtype: "SRV", callback: (err: NodeJS.ErrnoException | null, addresses: SrvRecord[]) => void): void;
174
- export function resolve(hostname: string, rrtype: "TXT", callback: (err: NodeJS.ErrnoException | null, addresses: string[][]) => void): void;
250
+ export function resolve(hostname: string, rrtype: 'A', callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
251
+ export function resolve(hostname: string, rrtype: 'AAAA', callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
252
+ export function resolve(hostname: string, rrtype: 'ANY', callback: (err: NodeJS.ErrnoException | null, addresses: AnyRecord[]) => void): void;
253
+ export function resolve(hostname: string, rrtype: 'CNAME', callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
254
+ export function resolve(hostname: string, rrtype: 'MX', callback: (err: NodeJS.ErrnoException | null, addresses: MxRecord[]) => void): void;
255
+ export function resolve(hostname: string, rrtype: 'NAPTR', callback: (err: NodeJS.ErrnoException | null, addresses: NaptrRecord[]) => void): void;
256
+ export function resolve(hostname: string, rrtype: 'NS', callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
257
+ export function resolve(hostname: string, rrtype: 'PTR', callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
258
+ export function resolve(hostname: string, rrtype: 'SOA', callback: (err: NodeJS.ErrnoException | null, addresses: SoaRecord) => void): void;
259
+ export function resolve(hostname: string, rrtype: 'SRV', callback: (err: NodeJS.ErrnoException | null, addresses: SrvRecord[]) => void): void;
260
+ export function resolve(hostname: string, rrtype: 'TXT', callback: (err: NodeJS.ErrnoException | null, addresses: string[][]) => void): void;
175
261
  export function resolve(
176
262
  hostname: string,
177
263
  rrtype: string,
178
- callback: (err: NodeJS.ErrnoException | null, addresses: string[] | MxRecord[] | NaptrRecord[] | SoaRecord | SrvRecord[] | string[][] | AnyRecord[]) => void,
264
+ callback: (err: NodeJS.ErrnoException | null, addresses: string[] | MxRecord[] | NaptrRecord[] | SoaRecord | SrvRecord[] | string[][] | AnyRecord[]) => void
179
265
  ): void;
180
-
181
- // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
182
266
  export namespace resolve {
183
- function __promisify__(hostname: string, rrtype?: "A" | "AAAA" | "CNAME" | "NS" | "PTR"): Promise<string[]>;
184
- function __promisify__(hostname: string, rrtype: "ANY"): Promise<AnyRecord[]>;
185
- function __promisify__(hostname: string, rrtype: "MX"): Promise<MxRecord[]>;
186
- function __promisify__(hostname: string, rrtype: "NAPTR"): Promise<NaptrRecord[]>;
187
- function __promisify__(hostname: string, rrtype: "SOA"): Promise<SoaRecord>;
188
- function __promisify__(hostname: string, rrtype: "SRV"): Promise<SrvRecord[]>;
189
- function __promisify__(hostname: string, rrtype: "TXT"): Promise<string[][]>;
267
+ function __promisify__(hostname: string, rrtype?: 'A' | 'AAAA' | 'CNAME' | 'NS' | 'PTR'): Promise<string[]>;
268
+ function __promisify__(hostname: string, rrtype: 'ANY'): Promise<AnyRecord[]>;
269
+ function __promisify__(hostname: string, rrtype: 'MX'): Promise<MxRecord[]>;
270
+ function __promisify__(hostname: string, rrtype: 'NAPTR'): Promise<NaptrRecord[]>;
271
+ function __promisify__(hostname: string, rrtype: 'SOA'): Promise<SoaRecord>;
272
+ function __promisify__(hostname: string, rrtype: 'SRV'): Promise<SrvRecord[]>;
273
+ function __promisify__(hostname: string, rrtype: 'TXT'): Promise<string[][]>;
190
274
  function __promisify__(hostname: string, rrtype: string): Promise<string[] | MxRecord[] | NaptrRecord[] | SoaRecord | SrvRecord[] | string[][] | AnyRecord[]>;
191
275
  }
192
-
276
+ /**
277
+ * Uses the DNS protocol to resolve a IPv4 addresses (`A` records) for the`hostname`. The `addresses` argument passed to the `callback` function
278
+ * will contain an array of IPv4 addresses (e.g.`['74.125.79.104', '74.125.79.105', '74.125.79.106']`).
279
+ * @since v0.1.16
280
+ * @param hostname Host name to resolve.
281
+ */
193
282
  export function resolve4(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
194
283
  export function resolve4(hostname: string, options: ResolveWithTtlOptions, callback: (err: NodeJS.ErrnoException | null, addresses: RecordWithTtl[]) => void): void;
195
284
  export function resolve4(hostname: string, options: ResolveOptions, callback: (err: NodeJS.ErrnoException | null, addresses: string[] | RecordWithTtl[]) => void): void;
196
-
197
- // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
198
285
  export namespace resolve4 {
199
286
  function __promisify__(hostname: string): Promise<string[]>;
200
287
  function __promisify__(hostname: string, options: ResolveWithTtlOptions): Promise<RecordWithTtl[]>;
201
288
  function __promisify__(hostname: string, options?: ResolveOptions): Promise<string[] | RecordWithTtl[]>;
202
289
  }
203
-
290
+ /**
291
+ * Uses the DNS protocol to resolve a IPv6 addresses (`AAAA` records) for the`hostname`. The `addresses` argument passed to the `callback` function
292
+ * will contain an array of IPv6 addresses.
293
+ * @since v0.1.16
294
+ * @param hostname Host name to resolve.
295
+ */
204
296
  export function resolve6(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
205
297
  export function resolve6(hostname: string, options: ResolveWithTtlOptions, callback: (err: NodeJS.ErrnoException | null, addresses: RecordWithTtl[]) => void): void;
206
298
  export function resolve6(hostname: string, options: ResolveOptions, callback: (err: NodeJS.ErrnoException | null, addresses: string[] | RecordWithTtl[]) => void): void;
207
-
208
- // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
209
299
  export namespace resolve6 {
210
300
  function __promisify__(hostname: string): Promise<string[]>;
211
301
  function __promisify__(hostname: string, options: ResolveWithTtlOptions): Promise<RecordWithTtl[]>;
212
302
  function __promisify__(hostname: string, options?: ResolveOptions): Promise<string[] | RecordWithTtl[]>;
213
303
  }
214
-
304
+ /**
305
+ * Uses the DNS protocol to resolve `CNAME` records for the `hostname`. The`addresses` argument passed to the `callback` function
306
+ * will contain an array of canonical name records available for the `hostname`(e.g. `['bar.example.com']`).
307
+ * @since v0.3.2
308
+ */
215
309
  export function resolveCname(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
216
310
  export namespace resolveCname {
217
311
  function __promisify__(hostname: string): Promise<string[]>;
218
312
  }
219
-
313
+ /**
314
+ * Uses the DNS protocol to resolve `CAA` records for the `hostname`. The`addresses` argument passed to the `callback` function
315
+ * will contain an array of certification authority authorization records
316
+ * available for the `hostname` (e.g. `[{critical: 0, iodef: 'mailto:pki@example.com'}, {critical: 128, issue: 'pki.example.com'}]`).
317
+ * @since v15.0.0
318
+ */
220
319
  export function resolveCaa(hostname: string, callback: (err: NodeJS.ErrnoException | null, records: CaaRecord[]) => void): void;
221
320
  export namespace resolveCaa {
222
321
  function __promisify__(hostname: string): Promise<CaaRecord[]>;
223
322
  }
224
-
323
+ /**
324
+ * Uses the DNS protocol to resolve mail exchange records (`MX` records) for the`hostname`. The `addresses` argument passed to the `callback` function will
325
+ * contain an array of objects containing both a `priority` and `exchange`property (e.g. `[{priority: 10, exchange: 'mx.example.com'}, ...]`).
326
+ * @since v0.1.27
327
+ */
225
328
  export function resolveMx(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: MxRecord[]) => void): void;
226
329
  export namespace resolveMx {
227
330
  function __promisify__(hostname: string): Promise<MxRecord[]>;
228
331
  }
229
-
332
+ /**
333
+ * Uses the DNS protocol to resolve regular expression based records (`NAPTR`records) for the `hostname`. The `addresses` argument passed to the `callback`function will contain an array of
334
+ * objects with the following properties:
335
+ *
336
+ * * `flags`
337
+ * * `service`
338
+ * * `regexp`
339
+ * * `replacement`
340
+ * * `order`
341
+ * * `preference`
342
+ *
343
+ * ```js
344
+ * {
345
+ * flags: 's',
346
+ * service: 'SIP+D2U',
347
+ * regexp: '',
348
+ * replacement: '_sip._udp.example.com',
349
+ * order: 30,
350
+ * preference: 100
351
+ * }
352
+ * ```
353
+ * @since v0.9.12
354
+ */
230
355
  export function resolveNaptr(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: NaptrRecord[]) => void): void;
231
356
  export namespace resolveNaptr {
232
357
  function __promisify__(hostname: string): Promise<NaptrRecord[]>;
233
358
  }
234
-
359
+ /**
360
+ * Uses the DNS protocol to resolve name server records (`NS` records) for the`hostname`. The `addresses` argument passed to the `callback` function will
361
+ * contain an array of name server records available for `hostname`(e.g. `['ns1.example.com', 'ns2.example.com']`).
362
+ * @since v0.1.90
363
+ */
235
364
  export function resolveNs(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
236
365
  export namespace resolveNs {
237
366
  function __promisify__(hostname: string): Promise<string[]>;
238
367
  }
239
-
368
+ /**
369
+ * Uses the DNS protocol to resolve pointer records (`PTR` records) for the`hostname`. The `addresses` argument passed to the `callback` function will
370
+ * be an array of strings containing the reply records.
371
+ * @since v6.0.0
372
+ */
240
373
  export function resolvePtr(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
241
374
  export namespace resolvePtr {
242
375
  function __promisify__(hostname: string): Promise<string[]>;
243
376
  }
244
-
377
+ /**
378
+ * Uses the DNS protocol to resolve a start of authority record (`SOA` record) for
379
+ * the `hostname`. The `address` argument passed to the `callback` function will
380
+ * be an object with the following properties:
381
+ *
382
+ * * `nsname`
383
+ * * `hostmaster`
384
+ * * `serial`
385
+ * * `refresh`
386
+ * * `retry`
387
+ * * `expire`
388
+ * * `minttl`
389
+ *
390
+ * ```js
391
+ * {
392
+ * nsname: 'ns.example.com',
393
+ * hostmaster: 'root.example.com',
394
+ * serial: 2013101809,
395
+ * refresh: 10000,
396
+ * retry: 2400,
397
+ * expire: 604800,
398
+ * minttl: 3600
399
+ * }
400
+ * ```
401
+ * @since v0.11.10
402
+ */
245
403
  export function resolveSoa(hostname: string, callback: (err: NodeJS.ErrnoException | null, address: SoaRecord) => void): void;
246
404
  export namespace resolveSoa {
247
405
  function __promisify__(hostname: string): Promise<SoaRecord>;
248
406
  }
249
-
407
+ /**
408
+ * Uses the DNS protocol to resolve service records (`SRV` records) for the`hostname`. The `addresses` argument passed to the `callback` function will
409
+ * be an array of objects with the following properties:
410
+ *
411
+ * * `priority`
412
+ * * `weight`
413
+ * * `port`
414
+ * * `name`
415
+ *
416
+ * ```js
417
+ * {
418
+ * priority: 10,
419
+ * weight: 5,
420
+ * port: 21223,
421
+ * name: 'service.example.com'
422
+ * }
423
+ * ```
424
+ * @since v0.1.27
425
+ */
250
426
  export function resolveSrv(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: SrvRecord[]) => void): void;
251
427
  export namespace resolveSrv {
252
428
  function __promisify__(hostname: string): Promise<SrvRecord[]>;
253
429
  }
254
-
430
+ /**
431
+ * Uses the DNS protocol to resolve text queries (`TXT` records) for the`hostname`. The `records` argument passed to the `callback` function is a
432
+ * two-dimensional array of the text records available for `hostname` (e.g.`[ ['v=spf1 ip4:0.0.0.0 ', '~all' ] ]`). Each sub-array contains TXT chunks of
433
+ * one record. Depending on the use case, these could be either joined together or
434
+ * treated separately.
435
+ * @since v0.1.27
436
+ */
255
437
  export function resolveTxt(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[][]) => void): void;
256
438
  export namespace resolveTxt {
257
439
  function __promisify__(hostname: string): Promise<string[][]>;
258
440
  }
259
-
441
+ /**
442
+ * Uses the DNS protocol to resolve all records (also known as `ANY` or `*` query).
443
+ * The `ret` argument passed to the `callback` function will be an array containing
444
+ * various types of records. Each object has a property `type` that indicates the
445
+ * type of the current record. And depending on the `type`, additional properties
446
+ * will be present on the object:
447
+ *
448
+ * <omitted>
449
+ *
450
+ * Here is an example of the `ret` object passed to the callback:
451
+ *
452
+ * ```js
453
+ * [ { type: 'A', address: '127.0.0.1', ttl: 299 },
454
+ * { type: 'CNAME', value: 'example.com' },
455
+ * { type: 'MX', exchange: 'alt4.aspmx.l.example.com', priority: 50 },
456
+ * { type: 'NS', value: 'ns1.example.com' },
457
+ * { type: 'TXT', entries: [ 'v=spf1 include:_spf.example.com ~all' ] },
458
+ * { type: 'SOA',
459
+ * nsname: 'ns1.example.com',
460
+ * hostmaster: 'admin.example.com',
461
+ * serial: 156696742,
462
+ * refresh: 900,
463
+ * retry: 900,
464
+ * expire: 1800,
465
+ * minttl: 60 } ]
466
+ * ```
467
+ *
468
+ * DNS server operators may choose not to respond to `ANY`queries. It may be better to call individual methods like {@link resolve4},{@link resolveMx}, and so on. For more details, see [RFC
469
+ * 8482](https://tools.ietf.org/html/rfc8482).
470
+ */
260
471
  export function resolveAny(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: AnyRecord[]) => void): void;
261
472
  export namespace resolveAny {
262
473
  function __promisify__(hostname: string): Promise<AnyRecord[]>;
263
474
  }
264
-
475
+ /**
476
+ * Performs a reverse DNS query that resolves an IPv4 or IPv6 address to an
477
+ * array of host names.
478
+ *
479
+ * On error, `err` is an `Error` object, where `err.code` is
480
+ * one of the `DNS error codes`.
481
+ * @since v0.1.16
482
+ */
265
483
  export function reverse(ip: string, callback: (err: NodeJS.ErrnoException | null, hostnames: string[]) => void): void;
484
+ /**
485
+ * Sets the IP address and port of servers to be used when performing DNS
486
+ * resolution. The `servers` argument is an array of [RFC 5952](https://tools.ietf.org/html/rfc5952#section-6) formatted
487
+ * addresses. If the port is the IANA default DNS port (53) it can be omitted.
488
+ *
489
+ * ```js
490
+ * dns.setServers([
491
+ * '4.4.4.4',
492
+ * '[2001:4860:4860::8888]',
493
+ * '4.4.4.4:1053',
494
+ * '[2001:4860:4860::8888]:1053',
495
+ * ]);
496
+ * ```
497
+ *
498
+ * An error will be thrown if an invalid address is provided.
499
+ *
500
+ * The `dns.setServers()` method must not be called while a DNS query is in
501
+ * progress.
502
+ *
503
+ * The {@link setServers} method affects only {@link resolve},`dns.resolve*()` and {@link reverse} (and specifically _not_ {@link lookup}).
504
+ *
505
+ * This method works much like[resolve.conf](https://man7.org/linux/man-pages/man5/resolv.conf.5.html).
506
+ * That is, if attempting to resolve with the first server provided results in a`NOTFOUND` error, the `resolve()` method will _not_ attempt to resolve with
507
+ * subsequent servers provided. Fallback DNS servers will only be used if the
508
+ * earlier ones time out or result in some other error.
509
+ * @since v0.11.3
510
+ * @param servers array of `RFC 5952` formatted addresses
511
+ */
266
512
  export function setServers(servers: ReadonlyArray<string>): void;
513
+ /**
514
+ * Returns an array of IP address strings, formatted according to [RFC 5952](https://tools.ietf.org/html/rfc5952#section-6),
515
+ * that are currently configured for DNS resolution. A string will include a port
516
+ * section if a custom port is used.
517
+ *
518
+ * ```js
519
+ * [
520
+ * '4.4.4.4',
521
+ * '2001:4860:4860::8888',
522
+ * '4.4.4.4:1053',
523
+ * '[2001:4860:4860::8888]:1053',
524
+ * ]
525
+ * ```
526
+ * @since v0.11.3
527
+ */
267
528
  export function getServers(): string[];
268
-
269
529
  // Error codes
270
530
  export const NODATA: string;
271
531
  export const FORMERR: string;
@@ -291,14 +551,54 @@ declare module 'dns' {
291
551
  export const LOADIPHLPAPI: string;
292
552
  export const ADDRGETNETWORKPARAMS: string;
293
553
  export const CANCELLED: string;
294
-
295
554
  export interface ResolverOptions {
296
555
  timeout?: number | undefined;
297
556
  }
298
-
557
+ /**
558
+ * An independent resolver for DNS requests.
559
+ *
560
+ * Creating a new resolver uses the default server settings. Setting
561
+ * the servers used for a resolver using `resolver.setServers()` does not affect
562
+ * other resolvers:
563
+ *
564
+ * ```js
565
+ * const { Resolver } = require('dns');
566
+ * const resolver = new Resolver();
567
+ * resolver.setServers(['4.4.4.4']);
568
+ *
569
+ * // This request will use the server at 4.4.4.4, independent of global settings.
570
+ * resolver.resolve4('example.org', (err, addresses) => {
571
+ * // ...
572
+ * });
573
+ * ```
574
+ *
575
+ * The following methods from the `dns` module are available:
576
+ *
577
+ * * `resolver.getServers()`
578
+ * * `resolver.resolve()`
579
+ * * `resolver.resolve4()`
580
+ * * `resolver.resolve6()`
581
+ * * `resolver.resolveAny()`
582
+ * * `resolver.resolveCaa()`
583
+ * * `resolver.resolveCname()`
584
+ * * `resolver.resolveMx()`
585
+ * * `resolver.resolveNaptr()`
586
+ * * `resolver.resolveNs()`
587
+ * * `resolver.resolvePtr()`
588
+ * * `resolver.resolveSoa()`
589
+ * * `resolver.resolveSrv()`
590
+ * * `resolver.resolveTxt()`
591
+ * * `resolver.reverse()`
592
+ * * `resolver.setServers()`
593
+ * @since v8.3.0
594
+ */
299
595
  export class Resolver {
300
596
  constructor(options?: ResolverOptions);
301
-
597
+ /**
598
+ * Cancel all outstanding DNS queries made by this resolver. The corresponding
599
+ * callbacks will be called with an error with code `ECANCELLED`.
600
+ * @since v8.3.0
601
+ */
302
602
  cancel(): void;
303
603
  getServers: typeof getServers;
304
604
  resolve: typeof resolve;
@@ -314,13 +614,26 @@ declare module 'dns' {
314
614
  resolveSrv: typeof resolveSrv;
315
615
  resolveTxt: typeof resolveTxt;
316
616
  reverse: typeof reverse;
617
+ /**
618
+ * The resolver instance will send its requests from the specified IP address.
619
+ * This allows programs to specify outbound interfaces when used on multi-homed
620
+ * systems.
621
+ *
622
+ * If a v4 or v6 address is not specified, it is set to the default, and the
623
+ * operating system will choose a local address automatically.
624
+ *
625
+ * The resolver will use the v4 local address when making requests to IPv4 DNS
626
+ * servers, and the v6 local address when making requests to IPv6 DNS servers.
627
+ * The `rrtype` of resolution requests has no impact on the local address used.
628
+ * @since v15.1.0
629
+ * @param ipv4 A string representation of an IPv4 address.
630
+ * @param ipv6 A string representation of an IPv6 address.
631
+ */
317
632
  setLocalAddress(ipv4?: string, ipv6?: string): void;
318
633
  setServers: typeof setServers;
319
634
  }
320
-
321
635
  export { dnsPromises as promises };
322
636
  }
323
-
324
637
  declare module 'node:dns' {
325
638
  export * from 'dns';
326
639
  }