UNPKG

dns-over-http-resolver

Version:
77 lines 2.73 kB
import type { DNSJSON } from './utils'; export interface Request { (resource: string, signal: AbortSignal): Promise<DNSJSON>; } interface ResolverOptions { maxCache?: number; request?: Request; } /** * DNS over HTTP resolver. * Uses a list of servers to resolve DNS records with HTTP requests. */ declare class Resolver { private readonly _cache; private readonly _TXTcache; private _servers; private readonly _request; private _abortControllers; /** * @class * @param {object} [options] * @param {number} [options.maxCache = 100] - maximum number of cached dns records * @param {Request} [options.request] - function to return DNSJSON */ constructor(options?: ResolverOptions); /** * Cancel all outstanding DNS queries made by this resolver. Any outstanding * requests will be aborted and promises rejected. */ cancel(): void; /** * Get an array of the IP addresses currently configured for DNS resolution. * These addresses are formatted according to RFC 5952. It can include a custom port. */ getServers(): string[]; /** * Get a shuffled array of the IP addresses currently configured for DNS resolution. * These addresses are formatted according to RFC 5952. It can include a custom port. */ _getShuffledServers(): string[]; /** * Sets the IP address and port of servers to be used when performing DNS resolution. * * @param {string[]} servers - array of RFC 5952 formatted addresses. */ setServers(servers: string[]): void; /** * Uses the DNS protocol to resolve the given host name into the appropriate DNS record * * @param {string} hostname - host name to resolve * @param {string} [rrType = 'A'] - resource record type */ resolve(hostname: string, rrType: 'TXT'): Promise<string[][]>; resolve(hostname: string, rrType: 'A' | 'AAAA'): Promise<string[]>; resolve(hostname: string): Promise<string[]>; /** * Uses the DNS protocol to resolve the given host name into IPv4 addresses * * @param {string} hostname - host name to resolve */ resolve4(hostname: string): Promise<string[]>; /** * Uses the DNS protocol to resolve the given host name into IPv6 addresses * * @param {string} hostname - host name to resolve */ resolve6(hostname: string): Promise<string[]>; /** * Uses the DNS protocol to resolve the given host name into a Text record * * @param {string} hostname - host name to resolve */ resolveTxt(hostname: string): Promise<string[][]>; clearCache(): void; } export default Resolver; //# sourceMappingURL=index.d.ts.map