deno.land / std@0.139.0 / node / dns.ts

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.// Copyright Joyent, Inc. and other Node contributors.//// Permission is hereby granted, free of charge, to any person obtaining a// copy of this software and associated documentation files (the// "Software"), to deal in the Software without restriction, including// without limitation the rights to use, copy, modify, merge, publish,// distribute, sublicense, and/or sell copies of the Software, and to permit// persons to whom the Software is furnished to do so, subject to the// following conditions://// The above copyright notice and this permission notice shall be included// in all copies or substantial portions of the Software.//// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE// USE OR OTHER DEALINGS IN THE SOFTWARE.
import { nextTick } from "./_next_tick.ts";import { customPromisifyArgs } from "./internal/util.mjs";import { validateBoolean, validateFunction, validateNumber, validateOneOf, validateString,} from "./internal/validators.mjs";import { isIP } from "./internal/net.ts";import { emitInvalidHostnameWarning, getDefaultResolver, getDefaultVerbatim, isFamily, isLookupCallback, isLookupOptions, isResolveCallback, Resolver as CallbackResolver, setDefaultResolver, setDefaultResultOrder, validateHints,} from "./internal/dns/utils.ts";import type { AnyAaaaRecord, AnyARecord, AnyCnameRecord, AnyMxRecord, AnyNaptrRecord, AnyNsRecord, AnyPtrRecord, AnyRecord, AnySoaRecord, AnySrvRecord, AnyTxtRecord, CaaRecord, LookupAddress, LookupAllOptions, LookupOneOptions, LookupOptions, MxRecord, NaptrRecord, Records, RecordWithTtl, ResolveCallback, ResolveOptions, ResolverOptions, ResolveWithTtlOptions, SoaRecord, SrvRecord,} from "./internal/dns/utils.ts";import promisesBase from "./internal/dns/promises.ts";import type { ErrnoException } from "./internal/errors.ts";import { dnsException, ERR_INVALID_ARG_TYPE, ERR_INVALID_ARG_VALUE,} from "./internal/errors.ts";import { AI_ADDRCONFIG as ADDRCONFIG, AI_ALL as ALL, AI_V4MAPPED as V4MAPPED,} from "./internal_binding/ares.ts";import { ChannelWrapQuery, getaddrinfo, GetAddrInfoReqWrap, QueryReqWrap,} from "./internal_binding/cares_wrap.ts";import { toASCII } from "./internal/idna.ts";import { notImplemented } from "./_utils.ts";
function onlookup( this: GetAddrInfoReqWrap, err: number | null, addresses: string[],) { if (err) { return this.callback(dnsException(err, "getaddrinfo", this.hostname)); }
this.callback(null, addresses[0], this.family || isIP(addresses[0]));}
function onlookupall( this: GetAddrInfoReqWrap, err: number | null, addresses: string[],) { if (err) { return this.callback(dnsException(err, "getaddrinfo", this.hostname)); }
const family = this.family; const parsedAddresses = [];
for (let i = 0; i < addresses.length; i++) { const addr = addresses[i]; parsedAddresses[i] = { address: addr, family: family || isIP(addr), }; }
this.callback(null, parsedAddresses);}
type LookupCallback = ( err: ErrnoException | null, addressOrAddresses?: string | LookupAddress[] | null, family?: number,) => void;
const validFamilies = [0, 4, 6];
// Easy DNS A/AAAA look up// lookup(hostname, [options,] callback)export function lookup( hostname: string, family: number, callback: ( err: ErrnoException | null, address: string, family: number, ) => void,): GetAddrInfoReqWrap | Record<string, never>;export function lookup( hostname: string, options: LookupOneOptions, callback: ( err: ErrnoException | null, address: string, family: number, ) => void,): GetAddrInfoReqWrap | Record<string, never>;export function lookup( hostname: string, options: LookupAllOptions, callback: (err: ErrnoException | null, addresses: LookupAddress[]) => void,): GetAddrInfoReqWrap | Record<string, never>;export function lookup( hostname: string, options: LookupOptions, callback: ( err: ErrnoException | null, address: string | LookupAddress[], family: number, ) => void,): GetAddrInfoReqWrap | Record<string, never>;export function lookup( hostname: string, callback: ( err: ErrnoException | null, address: string, family: number, ) => void,): GetAddrInfoReqWrap | Record<string, never>;export function lookup( hostname: string, options: unknown, callback?: unknown,): GetAddrInfoReqWrap | Record<string, never> { let hints = 0; let family = 0; let all = false; let verbatim = getDefaultVerbatim();
// Parse arguments if (hostname) { validateString(hostname, "hostname"); }
if (isLookupCallback(options)) { callback = options; family = 0; } else if (isFamily(options)) { validateFunction(callback, "callback");
validateOneOf(options, "family", validFamilies); family = options; } else if (!isLookupOptions(options)) { validateFunction(arguments.length === 2 ? options : callback, "callback");
throw new ERR_INVALID_ARG_TYPE("options", ["integer", "object"], options); } else { validateFunction(callback, "callback");
if (options?.hints != null) { validateNumber(options.hints, "options.hints"); hints = options.hints >>> 0; validateHints(hints); }
if (options?.family != null) { validateOneOf(options.family, "options.family", validFamilies); family = options.family; }
if (options?.all != null) { validateBoolean(options.all, "options.all"); all = options.all; }
if (options?.verbatim != null) { validateBoolean(options.verbatim, "options.verbatim"); verbatim = options.verbatim; } }
if (!hostname) { emitInvalidHostnameWarning(hostname);
if (all) { nextTick(callback as LookupCallback, null, []); } else { nextTick(callback as LookupCallback, null, null, family === 6 ? 6 : 4); }
return {}; }
const matchedFamily = isIP(hostname);
if (matchedFamily) { if (all) { nextTick(callback as LookupCallback, null, [ { address: hostname, family: matchedFamily }, ]); } else { nextTick(callback as LookupCallback, null, hostname, matchedFamily); }
return {}; }
const req = new GetAddrInfoReqWrap(); req.callback = callback as LookupCallback; req.family = family; req.hostname = hostname; req.oncomplete = all ? onlookupall : onlookup;
const err = getaddrinfo(req, toASCII(hostname), family, hints, verbatim);
if (err) { nextTick( callback as LookupCallback, dnsException(err, "getaddrinfo", hostname), );
return {}; }
return req;}
Object.defineProperty(lookup, customPromisifyArgs, { value: ["address", "family"], enumerable: false,});
function onresolve( this: QueryReqWrap, err: number, records: Records, ttls?: number[],): void { if (err) { this.callback(dnsException(err, this.bindingName, this.hostname));
return; }
const parsedRecords = ttls && this.ttl ? (records as string[]).map((address: string, index: number) => ({ address, ttl: ttls[index], })) : records;
this.callback(null, parsedRecords);}
function resolver(bindingName: keyof ChannelWrapQuery) { function query( this: Resolver, name: string, options: unknown, callback?: unknown, ): QueryReqWrap { if (isResolveCallback(options)) { callback = options; options = {}; }
validateString(name, "name"); validateFunction(callback, "callback");
const req = new QueryReqWrap(); req.bindingName = bindingName; req.callback = callback as ResolveCallback; req.hostname = name; req.oncomplete = onresolve;
if (options && (options as ResolveOptions).ttl) { notImplemented("dns.resolve* with ttl option"); }
req.ttl = !!(options && (options as ResolveOptions).ttl);
const err = this._handle[bindingName](req, toASCII(name));
if (err) { throw dnsException(err, bindingName, name); }
return req; }
Object.defineProperty(query, "name", { value: bindingName });
return query;}
const resolveMap = Object.create(null);
export class Resolver extends CallbackResolver { // deno-lint-ignore no-explicit-any [resolveMethod: string]: any}
Resolver.prototype.resolveAny = resolveMap.ANY = resolver("queryAny");Resolver.prototype.resolve4 = resolveMap.A = resolver("queryA");Resolver.prototype.resolve6 = resolveMap.AAAA = resolver("queryAaaa");Resolver.prototype.resolveCaa = resolveMap.CAA = resolver("queryCaa");Resolver.prototype.resolveCname = resolveMap.CNAME = resolver("queryCname");Resolver.prototype.resolveMx = resolveMap.MX = resolver("queryMx");Resolver.prototype.resolveNs = resolveMap.NS = resolver("queryNs");Resolver.prototype.resolveTxt = resolveMap.TXT = resolver("queryTxt");Resolver.prototype.resolveSrv = resolveMap.SRV = resolver("querySrv");Resolver.prototype.resolvePtr = resolveMap.PTR = resolver("queryPtr");Resolver.prototype.resolveNaptr = resolveMap.NAPTR = resolver("queryNaptr");Resolver.prototype.resolveSoa = resolveMap.SOA = resolver("querySoa");Resolver.prototype.reverse = resolver("getHostByAddr");Resolver.prototype.resolve = _resolve;
function _resolve( this: Resolver, hostname: string, rrtype: unknown, callback?: unknown,): QueryReqWrap { let resolver: Resolver;
if (typeof hostname !== "string") { throw new ERR_INVALID_ARG_TYPE("name", "string", hostname); }
if (typeof rrtype === "string") { resolver = resolveMap[rrtype]; } else if (typeof rrtype === "function") { resolver = resolveMap.A; callback = rrtype; } else { throw new ERR_INVALID_ARG_TYPE("rrtype", "string", rrtype); }
if (typeof resolver === "function") { return Reflect.apply(resolver, this, [hostname, callback]); }
throw new ERR_INVALID_ARG_VALUE("rrtype", rrtype);}
/** * Sets the IP address and port of servers to be used when performing DNS * resolution. The `servers` argument is an array of [RFC 5952](https://tools.ietf.org/html/rfc5952#section-6) formatted * addresses. If the port is the IANA default DNS port (53) it can be omitted. * * ```js * dns.setServers([ * '4.4.4.4', * '[2001:4860:4860::8888]', * '4.4.4.4:1053', * '[2001:4860:4860::8888]:1053', * ]); * ``` * * An error will be thrown if an invalid address is provided. * * The `dns.setServers()` method must not be called while a DNS query is in * progress. * * The `setServers` method affects only `resolve`,`dns.resolve*()` and `reverse` (and specifically _not_ `lookup`). * * This method works much like [resolve.conf](https://man7.org/linux/man-pages/man5/resolv.conf.5.html). * 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 * subsequent servers provided. Fallback DNS servers will only be used if the * earlier ones time out or result in some other error. * * @param servers array of `RFC 5952` formatted addresses */export function setServers(servers: ReadonlyArray<string>): void { const resolver = new Resolver();
resolver.setServers(servers); setDefaultResolver(resolver);}
// The Node implementation uses `bindDefaultResolver` to set the follow methods// on `module.exports` bound to the current `defaultResolver`. We don't have// the same ability in ESM but can simulate this (at some cost) by explicitly// exporting these methods which dynamically bind to the default resolver when// called.
/** * Returns an array of IP address strings, formatted according to [RFC 5952](https://tools.ietf.org/html/rfc5952#section-6), * that are currently configured for DNS resolution. A string will include a port * section if a custom port is used. * * ```js * [ * '4.4.4.4', * '2001:4860:4860::8888', * '4.4.4.4:1053', * '[2001:4860:4860::8888]:1053', * ] * ``` */export function getServers(): string[] { return Resolver.prototype.getServers.bind(getDefaultResolver())();}
/** * Uses the DNS protocol to resolve all records (also known as `ANY` or `*` query). * The `ret` argument passed to the `callback` function will be an array containing * various types of records. Each object has a property `type` that indicates the * type of the current record. And depending on the `type`, additional properties * will be present on the object. * * Here is an example of the `ret` object passed to the callback: * * ```js * [ { type: 'A', address: '127.0.0.1', ttl: 299 }, * { type: 'CNAME', value: 'example.com' }, * { type: 'MX', exchange: 'alt4.aspmx.l.example.com', priority: 50 }, * { type: 'NS', value: 'ns1.example.com' }, * { type: 'TXT', entries: [ 'v=spf1 include:_spf.example.com ~all' ] }, * { type: 'SOA', * nsname: 'ns1.example.com', * hostmaster: 'admin.example.com', * serial: 156696742, * refresh: 900, * retry: 900, * expire: 1800, * minttl: 60 } ] * ``` * * DNS server operators may choose not to respond to `ANY` queries. It may be * better to call individual methods like `resolve4`, `resolveMx`, and so on. * For more details, see [RFC 8482](https://tools.ietf.org/html/rfc8482). */export function resolveAny( hostname: string, callback: (err: ErrnoException | null, addresses: AnyRecord[]) => void,): QueryReqWrap { return Resolver.prototype.resolveAny.bind(getDefaultResolver() as Resolver)( hostname, callback, );}
/** * Uses the DNS protocol to resolve a IPv4 addresses (`A` records) for the * `hostname`. The `addresses` argument passed to the `callback` function will * contain an array of IPv4 addresses (e.g. `['74.125.79.104', '74.125.79.105','74.125.79.106']`). * * @param hostname Host name to resolve. */export function resolve4( hostname: string, callback: (err: ErrnoException | null, addresses: string[]) => void,): void;export function resolve4( hostname: string, options: ResolveWithTtlOptions, callback: (err: ErrnoException | null, addresses: RecordWithTtl[]) => void,): void;export function resolve4( hostname: string, options: ResolveOptions, callback: ( err: ErrnoException | null, addresses: string[] | RecordWithTtl[], ) => void,): void;export function resolve4( hostname: string, options: unknown, callback?: unknown,) { return Resolver.prototype.resolve4.bind(getDefaultResolver() as Resolver)( hostname, options, callback, );}
/** * Uses the DNS protocol to resolve a IPv6 addresses (`AAAA` records) for the * `hostname`. The `addresses` argument passed to the `callback` function * will contain an array of IPv6 addresses. * * @param hostname Host name to resolve. */export function resolve6( hostname: string, callback: (err: ErrnoException | null, addresses: string[]) => void,): void;export function resolve6( hostname: string, options: ResolveWithTtlOptions, callback: (err: ErrnoException | null, addresses: RecordWithTtl[]) => void,): void;export function resolve6( hostname: string, options: ResolveOptions, callback: ( err: ErrnoException | null, addresses: string[] | RecordWithTtl[], ) => void,): void;export function resolve6( hostname: string, options: unknown, callback?: unknown,) { return Resolver.prototype.resolve6.bind(getDefaultResolver() as Resolver)( hostname, options, callback, );}
/** * Uses the DNS protocol to resolve `CAA` records for the `hostname`. The * `addresses` argument passed to the `callback` function will contain an array * of certification authority authorization records available for the * `hostname` (e.g. `[{critical: 0, iodef: 'mailto:pki@example.com'}, {critical: 128, issue: 'pki.example.com'}]`). */export function resolveCaa( hostname: string, callback: (err: ErrnoException | null, records: CaaRecord[]) => void,): QueryReqWrap { return Resolver.prototype.resolveCaa.bind(getDefaultResolver() as Resolver)( hostname, callback, );}
/** * Uses the DNS protocol to resolve `CNAME` records for the `hostname`. The * `addresses` argument passed to the `callback` function will contain an array * of canonical name records available for the `hostname`(e.g. `['bar.example.com']`). */export function resolveCname( hostname: string, callback: (err: ErrnoException | null, addresses: string[]) => void,): QueryReqWrap { return Resolver.prototype.resolveCname.bind(getDefaultResolver() as Resolver)( hostname, callback, );}
/** * Uses the DNS protocol to resolve mail exchange records (`MX` records) for the * `hostname`. The `addresses` argument passed to the `callback` function will * contain an array of objects containing both a `priority` and `exchange` * property (e.g. `[{priority: 10, exchange: 'mx.example.com'}, ...]`). */export function resolveMx( hostname: string, callback: (err: ErrnoException | null, addresses: MxRecord[]) => void,): QueryReqWrap { return Resolver.prototype.resolveMx.bind(getDefaultResolver() as Resolver)( hostname, callback, );}
/** * Uses the DNS protocol to resolve name server records (`NS` records) for the * `hostname`. The `addresses` argument passed to the `callback` function will * contain an array of name server records available for `hostname` * (e.g. `['ns1.example.com', 'ns2.example.com']`). */export function resolveNs( hostname: string, callback: (err: ErrnoException | null, addresses: string[]) => void,): QueryReqWrap { return Resolver.prototype.resolveNs.bind(getDefaultResolver() as Resolver)( hostname, callback, );}
/** * Uses the DNS protocol to resolve text queries (`TXT` records) for the * `hostname`. The `records` argument passed to the `callback` function is a * 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 one record. Depending on the use case, these could be either * joined together or treated separately. */export function resolveTxt( hostname: string, callback: (err: ErrnoException | null, addresses: string[][]) => void,): QueryReqWrap { return Resolver.prototype.resolveTxt.bind(getDefaultResolver() as Resolver)( hostname, callback, );}
/** * Uses the DNS protocol to resolve service records (`SRV` records) for the * `hostname`. The `addresses` argument passed to the `callback` function will * be an array of objects with the following properties: * * - `priority` * - `weight` * - `port` * - `name` * * ```js * { * priority: 10, * weight: 5, * port: 21223, * name: 'service.example.com' * } * ``` */export function resolveSrv( hostname: string, callback: (err: ErrnoException | null, addresses: SrvRecord[]) => void,): QueryReqWrap { return Resolver.prototype.resolveSrv.bind(getDefaultResolver() as Resolver)( hostname, callback, );}
/** * Uses the DNS protocol to resolve pointer records (`PTR` records) for the * `hostname`. The `addresses` argument passed to the `callback` function will * be an array of strings containing the reply records. */export function resolvePtr( hostname: string, callback: (err: ErrnoException | null, addresses: string[]) => void,): QueryReqWrap { return Resolver.prototype.resolvePtr.bind(getDefaultResolver() as Resolver)( hostname, callback, );}
/** * 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 objects with the following * properties: * * - `flags` * - `service` * - `regexp` * - `replacement` * - `order` * - `preference` * * ```js * { * flags: 's', * service: 'SIP+D2U', * regexp: '', * replacement: '_sip._udp.example.com', * order: 30, * preference: 100 * } * ``` */export function resolveNaptr( hostname: string, callback: (err: ErrnoException | null, addresses: NaptrRecord[]) => void,): QueryReqWrap { return Resolver.prototype.resolveNaptr.bind(getDefaultResolver() as Resolver)( hostname, callback, );}
/** * Uses the DNS protocol to resolve a start of authority record (`SOA` record) for * the `hostname`. The `address` argument passed to the `callback` function will * be an object with the following properties: * * - `nsname` * - `hostmaster` * - `serial` * - `refresh` * - `retry` * - `expire` * - `minttl` * * ```js * { * nsname: 'ns.example.com', * hostmaster: 'root.example.com', * serial: 2013101809, * refresh: 10000, * retry: 2400, * expire: 604800, * minttl: 3600 * } * ``` */export function resolveSoa( hostname: string, callback: (err: ErrnoException | null, address: SoaRecord) => void,): QueryReqWrap { return Resolver.prototype.resolveSoa.bind(getDefaultResolver() as Resolver)( hostname, callback, );}
/** * Performs a reverse DNS query that resolves an IPv4 or IPv6 address to an * array of host names. * * On error, `err` is an `Error` object, where `err.code` is * one of the `DNS error codes`. */export function reverse( ip: string, callback: (err: ErrnoException | null, hostnames: string[]) => void,): QueryReqWrap { return Resolver.prototype.reverse.bind(getDefaultResolver() as Resolver)( ip, callback, );}
/** * Uses the DNS protocol to resolve a host name (e.g. `'nodejs.org'`) into an array * of the resource records. The `callback` function has arguments`(err, records)`.] * When successful, `records` will be an array of resource * records. The type and structure of individual results varies based on `rrtype`. * * On error, `err` is an `Error` object, where `err.code` is one of the DNS error codes. * * @param hostname Host name to resolve. * @param [rrtype='A'] Resource record type. */export function resolve( hostname: string, callback: (err: ErrnoException | null, addresses: string[]) => void,): QueryReqWrap;export function resolve( hostname: string, rrtype: "A", callback: (err: ErrnoException | null, addresses: string[]) => void,): QueryReqWrap;export function resolve( hostname: string, rrtype: "AAAA", callback: (err: ErrnoException | null, addresses: string[]) => void,): QueryReqWrap;export function resolve( hostname: string, rrtype: "ANY", callback: (err: ErrnoException | null, addresses: AnyRecord[]) => void,): QueryReqWrap;export function resolve( hostname: string, rrtype: "CNAME", callback: (err: ErrnoException | null, addresses: string[]) => void,): QueryReqWrap;export function resolve( hostname: string, rrtype: "MX", callback: (err: ErrnoException | null, addresses: MxRecord[]) => void,): QueryReqWrap;export function resolve( hostname: string, rrtype: "NAPTR", callback: (err: ErrnoException | null, addresses: NaptrRecord[]) => void,): QueryReqWrap;export function resolve( hostname: string, rrtype: "NS", callback: (err: ErrnoException | null, addresses: string[]) => void,): QueryReqWrap;export function resolve( hostname: string, rrtype: "PTR", callback: (err: ErrnoException | null, addresses: string[]) => void,): QueryReqWrap;export function resolve( hostname: string, rrtype: "SOA", callback: (err: ErrnoException | null, addresses: SoaRecord) => void,): QueryReqWrap;export function resolve( hostname: string, rrtype: "SRV", callback: (err: ErrnoException | null, addresses: SrvRecord[]) => void,): QueryReqWrap;export function resolve( hostname: string, rrtype: "TXT", callback: (err: ErrnoException | null, addresses: string[][]) => void,): QueryReqWrap;export function resolve( hostname: string, rrtype: string, callback: ( err: ErrnoException | null, addresses: | string[] | MxRecord[] | NaptrRecord[] | SoaRecord | SrvRecord[] | string[][] | AnyRecord[], ) => void,): QueryReqWrap;export function resolve(hostname: string, rrtype: unknown, callback?: unknown) { return Resolver.prototype.resolve.bind(getDefaultResolver() as Resolver)( hostname, rrtype, callback, );}
// ERROR CODESexport const NODATA = "ENODATA";export const FORMERR = "EFORMERR";export const SERVFAIL = "ESERVFAIL";export const NOTFOUND = "ENOTFOUND";export const NOTIMP = "ENOTIMP";export const REFUSED = "EREFUSED";export const BADQUERY = "EBADQUERY";export const BADNAME = "EBADNAME";export const BADFAMILY = "EBADFAMILY";export const BADRESP = "EBADRESP";export const CONNREFUSED = "ECONNREFUSED";export const TIMEOUT = "ETIMEOUT";export const EOF = "EOF";export const FILE = "EFILE";export const NOMEM = "ENOMEM";export const DESTRUCTION = "EDESTRUCTION";export const BADSTR = "EBADSTR";export const BADFLAGS = "EBADFLAGS";export const NONAME = "ENONAME";export const BADHINTS = "EBADHINTS";export const NOTINITIALIZED = "ENOTINITIALIZED";export const LOADIPHLPAPI = "ELOADIPHLPAPI";export const ADDRGETNETWORKPARAMS = "EADDRGETNETWORKPARAMS";export const CANCELLED = "ECANCELLED";
const promises = Object.defineProperties(promisesBase, { setServers: { configurable: true, enumerable: true, value: setServers, }, setDefaultResultOrder: { configurable: true, enumerable: true, value: setDefaultResultOrder, },});
export { ADDRCONFIG, ALL, promises, setDefaultResultOrder, V4MAPPED };
export type { AnyAaaaRecord, AnyARecord, AnyCnameRecord, AnyMxRecord, AnyNaptrRecord, AnyNsRecord, AnyPtrRecord, AnyRecord, AnySoaRecord, AnySrvRecord, AnyTxtRecord, CaaRecord, LookupAddress, LookupAllOptions, LookupOneOptions, LookupOptions, MxRecord, NaptrRecord, Records, RecordWithTtl, ResolveCallback, ResolveOptions, ResolverOptions, ResolveWithTtlOptions, SoaRecord, SrvRecord,};
export default { ADDRCONFIG, ALL, V4MAPPED, lookup, getServers, resolveAny, resolve4, resolve6, resolveCaa, resolveCname, resolveMx, resolveNs, resolveTxt, resolveSrv, resolvePtr, resolveNaptr, resolveSoa, resolve, reverse, setServers, setDefaultResultOrder, promises, NODATA, FORMERR, SERVFAIL, NOTFOUND, NOTIMP, REFUSED, BADQUERY, BADNAME, BADFAMILY, BADRESP, CONNREFUSED, TIMEOUT, EOF, FILE, NOMEM, DESTRUCTION, BADSTR, BADFLAGS, NONAME, BADHINTS, NOTINITIALIZED, LOADIPHLPAPI, ADDRGETNETWORKPARAMS, CANCELLED,};
std
Deno standard library
GitHub Stars
2178
Go to latest

Version Info

Tagged at
a month ago