Pinsave/counterstrike
1
1/**2 * The `dns.promises` API provides an alternative set of asynchronous DNS methods3 * that return `Promise` objects rather than using callbacks. The API is accessible4 * via `import { promises as dnsPromises } from 'node:dns'` or `import dnsPromises from 'node:dns/promises'`.5 * @since v10.6.06 */7declare module "dns/promises" {8 import {9 AnyRecord,10 CaaRecord,11 LookupAddress,12 LookupAllOptions,13 LookupOneOptions,14 LookupOptions,15 MxRecord,16 NaptrRecord,17 RecordWithTtl,18 ResolveOptions,19 ResolverOptions,20 ResolveWithTtlOptions,21 SoaRecord,22 SrvRecord,23 TlsaRecord,24 } from "node:dns";25 /**26 * Returns an array of IP address strings, formatted according to [RFC 5952](https://tools.ietf.org/html/rfc5952#section-6),27 * that are currently configured for DNS resolution. A string will include a port28 * section if a custom port is used.29 *30 * ```js31 * [32 * '4.4.4.4',33 * '2001:4860:4860::8888',34 * '4.4.4.4:1053',35 * '[2001:4860:4860::8888]:1053',36 * ]37 * ```38 * @since v10.6.039 */40 function getServers(): string[];41 /**42 * Resolves a host name (e.g. `'nodejs.org'`) into the first found A (IPv4) or43 * AAAA (IPv6) record. All `option` properties are optional. If `options` is an44 * integer, then it must be `4` or `6` โ if `options` is not provided, then IPv445 * and IPv6 addresses are both returned if found.46 *47 * With the `all` option set to `true`, the `Promise` is resolved with `addresses` being an array of objects with the properties `address` and `family`.48 *49 * On error, the `Promise` is rejected with an [`Error`](https://nodejs.org/docs/latest-v20.x/api/errors.html#class-error) object, where `err.code` is the error code.50 * Keep in mind that `err.code` will be set to `'ENOTFOUND'` not only when51 * the host name does not exist but also when the lookup fails in other ways52 * such as no available file descriptors.53 *54 * [`dnsPromises.lookup()`](https://nodejs.org/docs/latest-v20.x/api/dns.html#dnspromiseslookuphostname-options) does not necessarily have anything to do with the DNS55 * protocol. The implementation uses an operating system facility that can56 * associate names with addresses and vice versa. This implementation can have57 * subtle but important consequences on the behavior of any Node.js program. Please58 * take some time to consult the [Implementation considerations section](https://nodejs.org/docs/latest-v20.x/api/dns.html#implementation-considerations) before59 * using `dnsPromises.lookup()`.60 *61 * Example usage:62 *63 * ```js64 * import dns from 'node:dns';65 * const dnsPromises = dns.promises;66 * const options = {67 * family: 6,68 * hints: dns.ADDRCONFIG | dns.V4MAPPED,69 * };70 *71 * dnsPromises.lookup('example.com', options).then((result) => {72 * console.log('address: %j family: IPv%s', result.address, result.family);73 * // address: "2606:2800:220:1:248:1893:25c8:1946" family: IPv674 * });75 *76 * // When options.all is true, the result will be an Array.77 * options.all = true;78 * dnsPromises.lookup('example.com', options).then((result) => {79 * console.log('addresses: %j', result);80 * // addresses: [{"address":"2606:2800:220:1:248:1893:25c8:1946","family":6}]81 * });82 * ```83 * @since v10.6.084 */85 function lookup(hostname: string, family: number): Promise<LookupAddress>;86 function lookup(hostname: string, options: LookupOneOptions): Promise<LookupAddress>;87 function lookup(hostname: string, options: LookupAllOptions): Promise<LookupAddress[]>;88 function lookup(hostname: string, options: LookupOptions): Promise<LookupAddress | LookupAddress[]>;89 function lookup(hostname: string): Promise<LookupAddress>;90 /**91 * Resolves the given `address` and `port` into a host name and service using92 * the operating system's underlying `getnameinfo` implementation.93 *94 * If `address` is not a valid IP address, a `TypeError` will be thrown.95 * The `port` will be coerced to a number. If it is not a legal port, a `TypeError` will be thrown.96 *97 * On error, the `Promise` is rejected with an [`Error`](https://nodejs.org/docs/latest-v20.x/api/errors.html#class-error) object, where `err.code` is the error code.98 *99 * ```js100 * import dnsPromises from 'node:dns';101 * dnsPromises.lookupService('127.0.0.1', 22).then((result) => {102 * console.log(result.hostname, result.service);103 * // Prints: localhost ssh104 * });105 * ```106 * @since v10.6.0107 */108 function lookupService(109 address: string,110 port: number,111 ): Promise<{112 hostname: string;113 service: string;114 }>;115 /**116 * Uses the DNS protocol to resolve a host name (e.g. `'nodejs.org'`) into an array117 * of the resource records. When successful, the `Promise` is resolved with an118 * array of resource records. The type and structure of individual results vary119 * based on `rrtype`:120 *121 * <omitted>122 *123 * On error, the `Promise` is rejected with an [`Error`](https://nodejs.org/docs/latest-v20.x/api/errors.html#class-error) object, where `err.code`124 * is one of the [DNS error codes](https://nodejs.org/docs/latest-v20.x/api/dns.html#error-codes).125 * @since v10.6.0126 * @param hostname Host name to resolve.127 * @param [rrtype='A'] Resource record type.128 */129 function resolve(hostname: string): Promise<string[]>;130 function resolve(hostname: string, rrtype: "A" | "AAAA" | "CNAME" | "NS" | "PTR"): Promise<string[]>;131 function resolve(hostname: string, rrtype: "ANY"): Promise<AnyRecord[]>;132 function resolve(hostname: string, rrtype: "CAA"): Promise<CaaRecord[]>;133 function resolve(hostname: string, rrtype: "MX"): Promise<MxRecord[]>;134 function resolve(hostname: string, rrtype: "NAPTR"): Promise<NaptrRecord[]>;135 function resolve(hostname: string, rrtype: "SOA"): Promise<SoaRecord>;136 function resolve(hostname: string, rrtype: "SRV"): Promise<SrvRecord[]>;137 function resolve(hostname: string, rrtype: "TLSA"): Promise<TlsaRecord[]>;138 function resolve(hostname: string, rrtype: "TXT"): Promise<string[][]>;139 function resolve(hostname: string, rrtype: string): Promise<140 | string[]141 | CaaRecord[]142 | MxRecord[]143 | NaptrRecord[]144 | SoaRecord145 | SrvRecord[]146 | TlsaRecord[]147 | string[][]148 | AnyRecord[]149 >;150 /**151 * Uses the DNS protocol to resolve IPv4 addresses (`A` records) for the `hostname`. On success, the `Promise` is resolved with an array of IPv4152 * addresses (e.g. `['74.125.79.104', '74.125.79.105', '74.125.79.106']`).153 * @since v10.6.0154 * @param hostname Host name to resolve.155 */156 function resolve4(hostname: string): Promise<string[]>;157 function resolve4(hostname: string, options: ResolveWithTtlOptions): Promise<RecordWithTtl[]>;158 function resolve4(hostname: string, options: ResolveOptions): Promise<string[] | RecordWithTtl[]>;159 /**160 * Uses the DNS protocol to resolve IPv6 addresses (`AAAA` records) for the `hostname`. On success, the `Promise` is resolved with an array of IPv6161 * addresses.162 * @since v10.6.0163 * @param hostname Host name to resolve.164 */165 function resolve6(hostname: string): Promise<string[]>;166 function resolve6(hostname: string, options: ResolveWithTtlOptions): Promise<RecordWithTtl[]>;167 function resolve6(hostname: string, options: ResolveOptions): Promise<string[] | RecordWithTtl[]>;168 /**169 * Uses the DNS protocol to resolve all records (also known as `ANY` or `*` query).170 * On success, the `Promise` is resolved with an array containing various types of171 * records. Each object has a property `type` that indicates the type of the172 * current record. And depending on the `type`, additional properties will be173 * present on the object:174 *175 * <omitted>176 *177 * Here is an example of the result object:178 *179 * ```js180 * [ { type: 'A', address: '127.0.0.1', ttl: 299 },181 * { type: 'CNAME', value: 'example.com' },182 * { type: 'MX', exchange: 'alt4.aspmx.l.example.com', priority: 50 },183 * { type: 'NS', value: 'ns1.example.com' },184 * { type: 'TXT', entries: [ 'v=spf1 include:_spf.example.com ~all' ] },185 * { type: 'SOA',186 * nsname: 'ns1.example.com',187 * hostmaster: 'admin.example.com',188 * serial: 156696742,189 * refresh: 900,190 * retry: 900,191 * expire: 1800,192 * minttl: 60 } ]193 * ```194 * @since v10.6.0195 */196 function resolveAny(hostname: string): Promise<AnyRecord[]>;197 /**198 * Uses the DNS protocol to resolve `CAA` records for the `hostname`. On success,199 * the `Promise` is resolved with an array of objects containing available200 * certification authority authorization records available for the `hostname` (e.g. `[{critical: 0, iodef: 'mailto:pki@example.com'},{critical: 128, issue: 'pki.example.com'}]`).201 * @since v15.0.0, v14.17.0202 */203 function resolveCaa(hostname: string): Promise<CaaRecord[]>;204 /**205 * Uses the DNS protocol to resolve `CNAME` records for the `hostname`. On success,206 * the `Promise` is resolved with an array of canonical name records available for207 * the `hostname` (e.g. `['bar.example.com']`).208 * @since v10.6.0209 */210 function resolveCname(hostname: string): Promise<string[]>;211 /**212 * Uses the DNS protocol to resolve mail exchange records (`MX` records) for the `hostname`. On success, the `Promise` is resolved with an array of objects213 * containing both a `priority` and `exchange` property (e.g.`[{priority: 10, exchange: 'mx.example.com'}, ...]`).214 * @since v10.6.0215 */216 function resolveMx(hostname: string): Promise<MxRecord[]>;217 /**218 * Uses the DNS protocol to resolve regular expression-based records (`NAPTR` records) for the `hostname`. On success, the `Promise` is resolved with an array219 * of objects with the following properties:220 *221 * * `flags`222 * * `service`223 * * `regexp`224 * * `replacement`225 * * `order`226 * * `preference`227 *228 * ```js229 * {230 * flags: 's',231 * service: 'SIP+D2U',232 * regexp: '',233 * replacement: '_sip._udp.example.com',234 * order: 30,235 * preference: 100236 * }237 * ```238 * @since v10.6.0239 */240 function resolveNaptr(hostname: string): Promise<NaptrRecord[]>;241 /**242 * Uses the DNS protocol to resolve name server records (`NS` records) for the `hostname`. On success, the `Promise` is resolved with an array of name server243 * records available for `hostname` (e.g.`['ns1.example.com', 'ns2.example.com']`).244 * @since v10.6.0245 */246 function resolveNs(hostname: string): Promise<string[]>;247 /**248 * Uses the DNS protocol to resolve pointer records (`PTR` records) for the `hostname`. On success, the `Promise` is resolved with an array of strings249 * containing the reply records.250 * @since v10.6.0251 */252 function resolvePtr(hostname: string): Promise<string[]>;253 /**254 * Uses the DNS protocol to resolve a start of authority record (`SOA` record) for255 * the `hostname`. On success, the `Promise` is resolved with an object with the256 * following properties:257 *258 * * `nsname`259 * * `hostmaster`260 * * `serial`261 * * `refresh`262 * * `retry`263 * * `expire`264 * * `minttl`265 *266 * ```js267 * {268 * nsname: 'ns.example.com',269 * hostmaster: 'root.example.com',270 * serial: 2013101809,271 * refresh: 10000,272 * retry: 2400,273 * expire: 604800,274 * minttl: 3600275 * }276 * ```277 * @since v10.6.0278 */279 function resolveSoa(hostname: string): Promise<SoaRecord>;280 /**281 * Uses the DNS protocol to resolve service records (`SRV` records) for the `hostname`. On success, the `Promise` is resolved with an array of objects with282 * the following properties:283 *284 * * `priority`285 * * `weight`286 * * `port`287 * * `name`288 *289 * ```js290 * {291 * priority: 10,292 * weight: 5,293 * port: 21223,294 * name: 'service.example.com'295 * }296 * ```297 * @since v10.6.0298 */299 function resolveSrv(hostname: string): Promise<SrvRecord[]>;300 /**301 * Uses the DNS protocol to resolve certificate associations (`TLSA` records) for302 * the `hostname`. On success, the `Promise` is resolved with an array of objectsAdd commentMore actions303 * with these properties:304 *305 * * `certUsage`306 * * `selector`307 * * `match`308 * * `data`309 *310 * ```js311 * {312 * certUsage: 3,313 * selector: 1,314 * match: 1,315 * data: [ArrayBuffer]316 * }317 * ```318 * @since v23.9.0, v22.15.0319 */320 function resolveTlsa(hostname: string): Promise<TlsaRecord[]>;321 /**322 * Uses the DNS protocol to resolve text queries (`TXT` records) for the `hostname`. On success, the `Promise` is resolved with a two-dimensional array323 * of the text records available for `hostname` (e.g.`[ ['v=spf1 ip4:0.0.0.0 ', '~all' ] ]`). Each sub-array contains TXT chunks of324 * one record. Depending on the use case, these could be either joined together or325 * treated separately.326 * @since v10.6.0327 */328 function resolveTxt(hostname: string): Promise<string[][]>;329 /**330 * Performs a reverse DNS query that resolves an IPv4 or IPv6 address to an331 * array of host names.332 *333 * On error, the `Promise` is rejected with an [`Error`](https://nodejs.org/docs/latest-v20.x/api/errors.html#class-error) object, where `err.code`334 * is one of the [DNS error codes](https://nodejs.org/docs/latest-v20.x/api/dns.html#error-codes).335 * @since v10.6.0336 */337 function reverse(ip: string): Promise<string[]>;338 /**339 * Get the default value for `verbatim` in {@link lookup} and [dnsPromises.lookup()](https://nodejs.org/docs/latest-v20.x/api/dns.html#dnspromiseslookuphostname-options).340 * The value could be:341 *342 * * `ipv4first`: for `verbatim` defaulting to `false`.343 * * `verbatim`: for `verbatim` defaulting to `true`.344 * @since v20.1.0345 */346 function getDefaultResultOrder(): "ipv4first" | "verbatim";347 /**348 * Sets the IP address and port of servers to be used when performing DNS349 * resolution. The `servers` argument is an array of [RFC 5952](https://tools.ietf.org/html/rfc5952#section-6) formatted350 * addresses. If the port is the IANA default DNS port (53) it can be omitted.351 *352 * ```js353 * dnsPromises.setServers([354 * '4.4.4.4',355 * '[2001:4860:4860::8888]',356 * '4.4.4.4:1053',357 * '[2001:4860:4860::8888]:1053',358 * ]);359 * ```360 *361 * An error will be thrown if an invalid address is provided.362 *363 * The `dnsPromises.setServers()` method must not be called while a DNS query is in364 * progress.365 *366 * This method works much like [resolve.conf](https://man7.org/linux/man-pages/man5/resolv.conf.5.html).367 * That is, if attempting to resolve with the first server provided results in a `NOTFOUND` error, the `resolve()` method will _not_ attempt to resolve with368 * subsequent servers provided. Fallback DNS servers will only be used if the369 * earlier ones time out or result in some other error.370 * @since v10.6.0371 * @param servers array of `RFC 5952` formatted addresses372 */373 function setServers(servers: readonly string[]): void;374 /**375 * Set the default value of `order` in `dns.lookup()` and `{@link lookup}`. The value could be:376 *377 * * `ipv4first`: sets default `order` to `ipv4first`.378 * * `ipv6first`: sets default `order` to `ipv6first`.379 * * `verbatim`: sets default `order` to `verbatim`.380 *381 * The default is `verbatim` and [dnsPromises.setDefaultResultOrder()](https://nodejs.org/docs/latest-v20.x/api/dns.html#dnspromisessetdefaultresultorderorder)382 * have higher priority than [`--dns-result-order`](https://nodejs.org/docs/latest-v20.x/api/cli.html#--dns-result-orderorder).383 * When using [worker threads](https://nodejs.org/docs/latest-v20.x/api/worker_threads.html), [`dnsPromises.setDefaultResultOrder()`](https://nodejs.org/docs/latest-v20.x/api/dns.html#dnspromisessetdefaultresultorderorder)384 * from the main thread won't affect the default dns orders in workers.385 * @since v16.4.0, v14.18.0386 * @param order must be `'ipv4first'`, `'ipv6first'` or `'verbatim'`.387 */388 function setDefaultResultOrder(order: "ipv4first" | "ipv6first" | "verbatim"): void;389 // Error codes390 const NODATA: "ENODATA";391 const FORMERR: "EFORMERR";392 const SERVFAIL: "ESERVFAIL";393 const NOTFOUND: "ENOTFOUND";394 const NOTIMP: "ENOTIMP";395 const REFUSED: "EREFUSED";396 const BADQUERY: "EBADQUERY";397 const BADNAME: "EBADNAME";398 const BADFAMILY: "EBADFAMILY";399 const BADRESP: "EBADRESP";400 const CONNREFUSED: "ECONNREFUSED";401 const TIMEOUT: "ETIMEOUT";402 const EOF: "EOF";403 const FILE: "EFILE";404 const NOMEM: "ENOMEM";405 const DESTRUCTION: "EDESTRUCTION";406 const BADSTR: "EBADSTR";407 const BADFLAGS: "EBADFLAGS";408 const NONAME: "ENONAME";409 const BADHINTS: "EBADHINTS";410 const NOTINITIALIZED: "ENOTINITIALIZED";411 const LOADIPHLPAPI: "ELOADIPHLPAPI";412 const ADDRGETNETWORKPARAMS: "EADDRGETNETWORKPARAMS";413 const CANCELLED: "ECANCELLED";414 415 /**416 * An independent resolver for DNS requests.417 *418 * Creating a new resolver uses the default server settings. Setting419 * the servers used for a resolver using [`resolver.setServers()`](https://nodejs.org/docs/latest-v20.x/api/dns.html#dnspromisessetserversservers) does not affect420 * other resolvers:421 *422 * ```js423 * import { promises } from 'node:dns';424 * const resolver = new promises.Resolver();425 * resolver.setServers(['4.4.4.4']);426 *427 * // This request will use the server at 4.4.4.4, independent of global settings.428 * resolver.resolve4('example.org').then((addresses) => {429 * // ...430 * });431 *432 * // Alternatively, the same code can be written using async-await style.433 * (async function() {434 * const addresses = await resolver.resolve4('example.org');435 * })();436 * ```437 *438 * The following methods from the `dnsPromises` API are available:439 *440 * * `resolver.getServers()`441 * * `resolver.resolve()`442 * * `resolver.resolve4()`443 * * `resolver.resolve6()`444 * * `resolver.resolveAny()`445 * * `resolver.resolveCaa()`446 * * `resolver.resolveCname()`447 * * `resolver.resolveMx()`448 * * `resolver.resolveNaptr()`449 * * `resolver.resolveNs()`450 * * `resolver.resolvePtr()`451 * * `resolver.resolveSoa()`452 * * `resolver.resolveSrv()`453 * * `resolver.resolveTxt()`454 * * `resolver.reverse()`455 * * `resolver.setServers()`456 * @since v10.6.0457 */458 class Resolver {459 constructor(options?: ResolverOptions);460 /**461 * Cancel all outstanding DNS queries made by this resolver. The corresponding462 * callbacks will be called with an error with code `ECANCELLED`.463 * @since v8.3.0464 */465 cancel(): void;466 getServers: typeof getServers;467 resolve: typeof resolve;468 resolve4: typeof resolve4;469 resolve6: typeof resolve6;470 resolveAny: typeof resolveAny;471 resolveCaa: typeof resolveCaa;472 resolveCname: typeof resolveCname;473 resolveMx: typeof resolveMx;474 resolveNaptr: typeof resolveNaptr;475 resolveNs: typeof resolveNs;476 resolvePtr: typeof resolvePtr;477 resolveSoa: typeof resolveSoa;478 resolveSrv: typeof resolveSrv;479 resolveTlsa: typeof resolveTlsa;480 resolveTxt: typeof resolveTxt;481 reverse: typeof reverse;482 /**483 * The resolver instance will send its requests from the specified IP address.484 * This allows programs to specify outbound interfaces when used on multi-homed485 * systems.486 *487 * If a v4 or v6 address is not specified, it is set to the default and the488 * operating system will choose a local address automatically.489 *490 * The resolver will use the v4 local address when making requests to IPv4 DNS491 * servers, and the v6 local address when making requests to IPv6 DNS servers.492 * The `rrtype` of resolution requests has no impact on the local address used.493 * @since v15.1.0, v14.17.0494 * @param [ipv4='0.0.0.0'] A string representation of an IPv4 address.495 * @param [ipv6='::0'] A string representation of an IPv6 address.496 */497 setLocalAddress(ipv4?: string, ipv6?: string): void;498 setServers: typeof setServers;499 }500}501declare module "node:dns/promises" {502 export * from "dns/promises";503}504 