UNPKG

28.9 kBTypeScriptView Raw
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 */
47declare module 'dns' {
48 import * as dnsPromises from 'node:dns/promises';
49 // Supported getaddrinfo flags.
50 export const ADDRCONFIG: number;
51 export const V4MAPPED: number;
52 /**
53 * If `dns.V4MAPPED` is specified, return resolved IPv6 addresses as
54 * well as IPv4 mapped IPv6 addresses.
55 */
56 export const ALL: number;
57 export interface LookupOptions {
58 family?: number | undefined;
59 hints?: number | undefined;
60 all?: boolean | undefined;
61 verbatim?: boolean | undefined;
62 }
63 export interface LookupOneOptions extends LookupOptions {
64 all?: false | undefined;
65 }
66 export interface LookupAllOptions extends LookupOptions {
67 all: true;
68 }
69 export interface LookupAddress {
70 address: string;
71 family: number;
72 }
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 */
115 export function lookup(hostname: string, family: number, callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void): void;
116 export function lookup(hostname: string, options: LookupOneOptions, callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void): void;
117 export function lookup(hostname: string, options: LookupAllOptions, callback: (err: NodeJS.ErrnoException | null, addresses: LookupAddress[]) => void): void;
118 export function lookup(hostname: string, options: LookupOptions, callback: (err: NodeJS.ErrnoException | null, address: string | LookupAddress[], family: number) => void): void;
119 export function lookup(hostname: string, callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void): void;
120 export namespace lookup {
121 function __promisify__(hostname: string, options: LookupAllOptions): Promise<LookupAddress[]>;
122 function __promisify__(hostname: string, options?: LookupOneOptions | number): Promise<LookupAddress>;
123 function __promisify__(hostname: string, options: LookupOptions): Promise<LookupAddress | LookupAddress[]>;
124 }
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 */
145 export function lookupService(address: string, port: number, callback: (err: NodeJS.ErrnoException | null, hostname: string, service: string) => void): void;
146 export namespace lookupService {
147 function __promisify__(
148 address: string,
149 port: number
150 ): Promise<{
151 hostname: string;
152 service: string;
153 }>;
154 }
155 export interface ResolveOptions {
156 ttl: boolean;
157 }
158 export interface ResolveWithTtlOptions extends ResolveOptions {
159 ttl: true;
160 }
161 export interface RecordWithTtl {
162 address: string;
163 ttl: number;
164 }
165 /** @deprecated Use `AnyARecord` or `AnyAaaaRecord` instead. */
166 export type AnyRecordWithTtl = AnyARecord | AnyAaaaRecord;
167 export interface AnyARecord extends RecordWithTtl {
168 type: 'A';
169 }
170 export interface AnyAaaaRecord extends RecordWithTtl {
171 type: 'AAAA';
172 }
173 export interface CaaRecord {
174 critial: number;
175 issue?: string | undefined;
176 issuewild?: string | undefined;
177 iodef?: string | undefined;
178 contactemail?: string | undefined;
179 contactphone?: string | undefined;
180 }
181 export interface MxRecord {
182 priority: number;
183 exchange: string;
184 }
185 export interface AnyMxRecord extends MxRecord {
186 type: 'MX';
187 }
188 export interface NaptrRecord {
189 flags: string;
190 service: string;
191 regexp: string;
192 replacement: string;
193 order: number;
194 preference: number;
195 }
196 export interface AnyNaptrRecord extends NaptrRecord {
197 type: 'NAPTR';
198 }
199 export interface SoaRecord {
200 nsname: string;
201 hostmaster: string;
202 serial: number;
203 refresh: number;
204 retry: number;
205 expire: number;
206 minttl: number;
207 }
208 export interface AnySoaRecord extends SoaRecord {
209 type: 'SOA';
210 }
211 export interface SrvRecord {
212 priority: number;
213 weight: number;
214 port: number;
215 name: string;
216 }
217 export interface AnySrvRecord extends SrvRecord {
218 type: 'SRV';
219 }
220 export interface AnyTxtRecord {
221 type: 'TXT';
222 entries: string[];
223 }
224 export interface AnyNsRecord {
225 type: 'NS';
226 value: string;
227 }
228 export interface AnyPtrRecord {
229 type: 'PTR';
230 value: string;
231 }
232 export interface AnyCnameRecord {
233 type: 'CNAME';
234 value: string;
235 }
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='A'] Resource record type.
248 */
249 export function resolve(hostname: string, 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;
261 export function resolve(
262 hostname: string,
263 rrtype: string,
264 callback: (err: NodeJS.ErrnoException | null, addresses: string[] | MxRecord[] | NaptrRecord[] | SoaRecord | SrvRecord[] | string[][] | AnyRecord[]) => void
265 ): void;
266 export namespace resolve {
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[][]>;
274 function __promisify__(hostname: string, rrtype: string): Promise<string[] | MxRecord[] | NaptrRecord[] | SoaRecord | SrvRecord[] | string[][] | AnyRecord[]>;
275 }
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 */
282 export function resolve4(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
283 export function resolve4(hostname: string, options: ResolveWithTtlOptions, callback: (err: NodeJS.ErrnoException | null, addresses: RecordWithTtl[]) => void): void;
284 export function resolve4(hostname: string, options: ResolveOptions, callback: (err: NodeJS.ErrnoException | null, addresses: string[] | RecordWithTtl[]) => void): void;
285 export namespace resolve4 {
286 function __promisify__(hostname: string): Promise<string[]>;
287 function __promisify__(hostname: string, options: ResolveWithTtlOptions): Promise<RecordWithTtl[]>;
288 function __promisify__(hostname: string, options?: ResolveOptions): Promise<string[] | RecordWithTtl[]>;
289 }
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 */
296 export function resolve6(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
297 export function resolve6(hostname: string, options: ResolveWithTtlOptions, callback: (err: NodeJS.ErrnoException | null, addresses: RecordWithTtl[]) => void): void;
298 export function resolve6(hostname: string, options: ResolveOptions, callback: (err: NodeJS.ErrnoException | null, addresses: string[] | RecordWithTtl[]) => void): void;
299 export namespace resolve6 {
300 function __promisify__(hostname: string): Promise<string[]>;
301 function __promisify__(hostname: string, options: ResolveWithTtlOptions): Promise<RecordWithTtl[]>;
302 function __promisify__(hostname: string, options?: ResolveOptions): Promise<string[] | RecordWithTtl[]>;
303 }
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 */
309 export function resolveCname(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
310 export namespace resolveCname {
311 function __promisify__(hostname: string): Promise<string[]>;
312 }
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 */
319 export function resolveCaa(hostname: string, callback: (err: NodeJS.ErrnoException | null, records: CaaRecord[]) => void): void;
320 export namespace resolveCaa {
321 function __promisify__(hostname: string): Promise<CaaRecord[]>;
322 }
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 */
328 export function resolveMx(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: MxRecord[]) => void): void;
329 export namespace resolveMx {
330 function __promisify__(hostname: string): Promise<MxRecord[]>;
331 }
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 */
355 export function resolveNaptr(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: NaptrRecord[]) => void): void;
356 export namespace resolveNaptr {
357 function __promisify__(hostname: string): Promise<NaptrRecord[]>;
358 }
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 */
364 export function resolveNs(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
365 export namespace resolveNs {
366 function __promisify__(hostname: string): Promise<string[]>;
367 }
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 */
373 export function resolvePtr(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
374 export namespace resolvePtr {
375 function __promisify__(hostname: string): Promise<string[]>;
376 }
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 */
403 export function resolveSoa(hostname: string, callback: (err: NodeJS.ErrnoException | null, address: SoaRecord) => void): void;
404 export namespace resolveSoa {
405 function __promisify__(hostname: string): Promise<SoaRecord>;
406 }
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 */
426 export function resolveSrv(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: SrvRecord[]) => void): void;
427 export namespace resolveSrv {
428 function __promisify__(hostname: string): Promise<SrvRecord[]>;
429 }
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 */
437 export function resolveTxt(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[][]) => void): void;
438 export namespace resolveTxt {
439 function __promisify__(hostname: string): Promise<string[][]>;
440 }
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 */
471 export function resolveAny(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: AnyRecord[]) => void): void;
472 export namespace resolveAny {
473 function __promisify__(hostname: string): Promise<AnyRecord[]>;
474 }
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 */
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 */
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 */
528 export function getServers(): string[];
529 // Error codes
530 export const NODATA: string;
531 export const FORMERR: string;
532 export const SERVFAIL: string;
533 export const NOTFOUND: string;
534 export const NOTIMP: string;
535 export const REFUSED: string;
536 export const BADQUERY: string;
537 export const BADNAME: string;
538 export const BADFAMILY: string;
539 export const BADRESP: string;
540 export const CONNREFUSED: string;
541 export const TIMEOUT: string;
542 export const EOF: string;
543 export const FILE: string;
544 export const NOMEM: string;
545 export const DESTRUCTION: string;
546 export const BADSTR: string;
547 export const BADFLAGS: string;
548 export const NONAME: string;
549 export const BADHINTS: string;
550 export const NOTINITIALIZED: string;
551 export const LOADIPHLPAPI: string;
552 export const ADDRGETNETWORKPARAMS: string;
553 export const CANCELLED: string;
554 export interface ResolverOptions {
555 timeout?: number | undefined;
556 }
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 */
595 export class Resolver {
596 constructor(options?: ResolverOptions);
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 */
602 cancel(): void;
603 getServers: typeof getServers;
604 resolve: typeof resolve;
605 resolve4: typeof resolve4;
606 resolve6: typeof resolve6;
607 resolveAny: typeof resolveAny;
608 resolveCname: typeof resolveCname;
609 resolveMx: typeof resolveMx;
610 resolveNaptr: typeof resolveNaptr;
611 resolveNs: typeof resolveNs;
612 resolvePtr: typeof resolvePtr;
613 resolveSoa: typeof resolveSoa;
614 resolveSrv: typeof resolveSrv;
615 resolveTxt: typeof resolveTxt;
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='0.0.0.0'] A string representation of an IPv4 address.
630 * @param [ipv6='::0'] A string representation of an IPv6 address.
631 */
632 setLocalAddress(ipv4?: string, ipv6?: string): void;
633 setServers: typeof setServers;
634 }
635 export { dnsPromises as promises };
636}
637declare module 'node:dns' {
638 export * from 'dns';
639}