Bare Docs

bare-dns

Domain name resolution for JavaScript

Documented against v2.3.0
stable

bare-dns — Domain name resolution for JavaScript. It is a native addon and requires Bare >=1.33.0. A Bare older than that refuses to load it with an UNSUPPORTED_ENGINE error on every platform, not only Android. v2.2.1 required >=1.7.0.

Mirrors the Node.js dns module.

npm i bare-dns

Usage

const dns = require('bare-dns')

dns.lookup('github.com', (err, address, family) => {
  console.log(address, family)
})

Android

Added in v2.3.0. bare-dns sends its DNS protocol queries with c-ares. The c-ares documentation says that on Android 8 and newer, the system's DNS servers can only be read through the application's ConnectivityManager, and that the application needs the ACCESS_NETWORK_STATE permission. The ConnectivityManager has to come from the host application, so the addon asks the host for it.

When the addon first loads in the operating system process, it reads two keys from the embedder context: bare.android.jvm.v1 and bare.android.context.v1. It calls getSystemService("connectivity") on the application context, then passes the JVM and the ConnectivityManager to c-ares. The host must publish both keys before the first addon loads. The thread that loads the addon must be attached to the JVM, because the addon calls GetEnv() on it and asserts that the call succeeds. As of bare-kit 2.5.5, Bare Kit publishes bare.android.jvm.v1 but not bare.android.context.v1, so an application that embeds Bare through Bare Kit skips this step unless something else publishes that key.

If either key is not published, or the ConnectivityManager cannot be obtained, the addon skips this step without an error. c-ares then has no manager, and its documentation says DNS resolution does not work on Android 8 or newer without one when the application targets API level 26 or higher. dns.lookup() uses the operating system's getaddrinfo() and does not depend on any of this.

API

dns

dns.AnyRecord

type AnyRecord = | ({ type: 'A' } & RecordWithTTL)
  | ({ type: 'AAAA' } & RecordWithTTL)
  | { type: 'CNAME'; value: string }
  | { type: 'NS'; value: string }
  | { type: 'PTR'; value: string }
  | { type: 'TXT'; entries: string[] }
  | ({ type: 'MX' } & MXRecord)
  | ({ type: 'SRV' } & SRVRecord)
  | ({ type: 'NAPTR' } & NAPTRRecord)
  | ({ type: 'SOA' } & SOARecord)

dns.cancel(): void

dns.constants

dns.constants: {
  readonly type: {
    readonly A: 1
    readonly NS: 2
    readonly CNAME: 5
    readonly SOA: 6
    readonly PTR: 12
    readonly HINFO: 13
    readonly MX: 15
    readonly TXT: 16
    readonly SIG: 24
    readonly AAAA: 28
    readonly SRV: 33
    readonly NAPTR: 35
    readonly OPT: 41
    readonly TLSA: 52
    readonly SVCB: 64
    readonly HTTPS: 65
    readonly ANY: 255
    readonly URI: 256
    readonly CAA: 257
  }
  readonly status: Record<string, number>
}

dns.getServers(): string[]

dns.IPFamily

type IPFamily = 4 | 6

The IP address family: 4 for IPv4 or 6 for IPv6.

dns.lookup

dns.lookup(hostname: string, cb: (err: Error | null, address: string | null, family: IPFamily | 0) => void): void

Resolve hostname into an IP address using the operating system's getaddrinfo facility, not the DNS protocol directly. With all: true, the callback receives every resolved address instead of just the first.

Parameters

ParameterTypeDefaultDescription
hostnamestring—The host name to resolve.
cb(err: Error | null, address: string | null, family: IPFamily | 0) => void—Called with (err, address, family), or (err, addresses) when all: true.

dns.RecordType

type RecordType = | 'A'
  | 'AAAA'
  | 'ANY'
  | 'CAA'
  | 'CNAME'
  | 'MX'
  | 'NAPTR'
  | 'NS'
  | 'PTR'
  | 'SOA'
  | 'SRV'
  | 'TLSA'
  | 'TXT'

dns.resolve: DNSResolver['resolve']

dns.resolve4: DNSResolver['resolve4']

dns.resolve6: DNSResolver['resolve6']

dns.resolveAny: DNSResolver['resolveAny']

dns.resolveCaa: DNSResolver['resolveCaa']

dns.resolveCname: DNSResolver['resolveCname']

dns.resolveMx: DNSResolver['resolveMx']

dns.resolveNaptr: DNSResolver['resolveNaptr']

dns.resolveNs: DNSResolver['resolveNs']

dns.resolvePtr: DNSResolver['resolvePtr']

dns.resolveSoa: DNSResolver['resolveSoa']

dns.resolveSrv: DNSResolver['resolveSrv']

dns.resolveTlsa: DNSResolver['resolveTlsa']

dns.resolveTxt: DNSResolver['resolveTxt']

Use the DNS protocol to resolve TXT records for hostname, on the global resolver. The callback receives an array of records, each itself an array of the strings that make up that record.

dns.reverse: DNSResolver['reverse']

dns.setLocalAddress(ipv4?: string | null, ipv6?: string | null): void

Parameters

ParameterTypeDefaultDescription
ipv4?string | null——
ipv6?string | null——

dns.setServers(servers: string[]): void

Parameters

ParameterTypeDefaultDescription
serversstring[]——

DNSResolver

The module exports this class as dns.Resolver, so create one with new dns.Resolver(). DNSResolver is its name in the type declarations, and dns.DNSResolver does not exist.

new DNSResolver(opts?: DNSResolverOptions)

An independent resolver for DNS queries over the DNS protocol, with its own servers and local address. Each instance keeps its own set of outstanding queries, which cancel() aborts and destroy() releases.

Parameters

ParameterTypeDefaultDescription
opts?DNSResolverOptions——

DNSResolver.cancel(): void

Aborts every query outstanding on this resolver. Each pending callback is invoked with ECANCELLED.

DNSResolver.destroy(): void

Cancels every query outstanding on this resolver, so that none is left without an answer, and releases the resources it holds. A query made after this throws.

DNSResolver.global: DNSResolver

DNSResolver.getServers(): string[]

resolve(hostname: string, cb: Callback<string[]>): void

Overloads:

resolve(hostname: string, cb: Callback<string[]>): void
resolve(hostname: string, rrtype: 'A' | 'AAAA' | 'CNAME' | 'NS' | 'PTR', cb: Callback<string[]>): void
resolve(hostname: string, rrtype: 'TXT', cb: Callback<string[][]>): void
resolve(hostname: string, rrtype: 'MX', cb: Callback<MXRecord[]>): void
resolve(hostname: string, rrtype: 'SRV', cb: Callback<SRVRecord[]>): void
resolve(hostname: string, rrtype: 'NAPTR', cb: Callback<NAPTRRecord[]>): void
resolve(hostname: string, rrtype: 'SOA', cb: Callback<SOARecord>): void
resolve(hostname: string, rrtype: 'CAA', cb: Callback<CAARecord[]>): void
resolve(hostname: string, rrtype: 'TLSA', cb: Callback<TLSARecord[]>): void
resolve(hostname: string, rrtype: 'ANY', cb: Callback<AnyRecord[]>): void

Parameters

ParameterTypeDefaultDescription
hostnamestring——
cbCallback<string[]>——

resolve4(hostname: string, cb: Callback<string[]>): void

Overloads:

resolve4(hostname: string, cb: Callback<string[]>): void
resolve4(hostname: string, opts: { ttl?: false }, cb: Callback<string[]>): void
resolve4(hostname: string, opts: { ttl: true }, cb: Callback<RecordWithTTL[]>): void

Parameters

ParameterTypeDefaultDescription
hostnamestring——
cbCallback<string[]>——

resolve6(hostname: string, cb: Callback<string[]>): void

Overloads:

resolve6(hostname: string, cb: Callback<string[]>): void
resolve6(hostname: string, opts: { ttl?: false }, cb: Callback<string[]>): void
resolve6(hostname: string, opts: { ttl: true }, cb: Callback<RecordWithTTL[]>): void

Parameters

ParameterTypeDefaultDescription
hostnamestring——
cbCallback<string[]>——

resolveAny(hostname: string, cb: Callback<AnyRecord[]>): void

Parameters

ParameterTypeDefaultDescription
hostnamestring——
cbCallback<AnyRecord[]>——

resolveCaa(hostname: string, cb: Callback<CAARecord[]>): void

Parameters

ParameterTypeDefaultDescription
hostnamestring——
cbCallback<CAARecord[]>——

resolveCname(hostname: string, cb: Callback<string[]>): void

Parameters

ParameterTypeDefaultDescription
hostnamestring——
cbCallback<string[]>——

resolveMx(hostname: string, cb: Callback<MXRecord[]>): void

Parameters

ParameterTypeDefaultDescription
hostnamestring——
cbCallback<MXRecord[]>——

resolveNaptr(hostname: string, cb: Callback<NAPTRRecord[]>): void

Parameters

ParameterTypeDefaultDescription
hostnamestring——
cbCallback<NAPTRRecord[]>——

resolveNs(hostname: string, cb: Callback<string[]>): void

Parameters

ParameterTypeDefaultDescription
hostnamestring——
cbCallback<string[]>——

resolvePtr(hostname: string, cb: Callback<string[]>): void

Parameters

ParameterTypeDefaultDescription
hostnamestring——
cbCallback<string[]>——

resolveSoa(hostname: string, cb: Callback<SOARecord>): void

Parameters

ParameterTypeDefaultDescription
hostnamestring——
cbCallback<SOARecord>——

resolveSrv(hostname: string, cb: Callback<SRVRecord[]>): void

Parameters

ParameterTypeDefaultDescription
hostnamestring——
cbCallback<SRVRecord[]>——

resolveTlsa(hostname: string, cb: Callback<TLSARecord[]>): void

Parameters

ParameterTypeDefaultDescription
hostnamestring——
cbCallback<TLSARecord[]>——

resolveTxt(hostname: string, cb: Callback<string[][]>): void

Use the DNS protocol to resolve TXT records for hostname. The callback receives an array of records, each itself an array of the strings that make up that record.

Parameters

ParameterTypeDefaultDescription
hostnamestring—The host name to query TXT records for.
cbCallback<string[][]>—Called with (err, records); each record is an array of the strings it is made of.

reverse(ip: string, cb: Callback<string[]>): void

Resolves the pointer records for ip.

This queries the reverse zone for the address only. Unlike Node.js, the hosts file is not consulted first, so an address that is only named there does not resolve.

Parameters

ParameterTypeDefaultDescription
ipstring——
cbCallback<string[]>——

DNSResolver.setLocalAddress(ipv4?: string | null, ipv6?: string | null): void

Parameters

ParameterTypeDefaultDescription
ipv4?string | null——
ipv6?string | null——

DNSResolver.setServers(servers: string[]): void

Parameters

ParameterTypeDefaultDescription
serversstring[]——

DNSError

The module exports this class as dns.errors, which is the same class as require('bare-dns/errors').

DNSError.code: string

DNSError.INVALID_IP_ADDRESS(msg?: string): DNSError

Parameters

ParameterTypeDefaultDescription
msg?string——

DNSError.query(status: number, syscall: string, hostname?: string | null): DNSError

Parameters

ParameterTypeDefaultDescription
statusnumber——
syscallstring——
hostname?string | null——

DNSError.RESOLVER_DESTROYED(msg?: string): DNSError

Parameters

ParameterTypeDefaultDescription
msg?string——

DNSError.UNKNOWN_RECORD_TYPE(msg?: string): DNSError

Parameters

ParameterTypeDefaultDescription
msg?string——

DNSError.hostname: string

Present on errors created by DNSError.query() for a named host.

DNSError.name: 'DNSError'

DNSError.syscall: string

Present on errors created by DNSError.query().

Types

LookupOptions

interface LookupOptions {
  family?: `IPv${IPFamily}` | IPFamily | 0
  hints?: number
  all?: boolean
}

DNSResolverOptions

interface DNSResolverOptions {
  servers?: string[]
  localAddress?: { ipv4?: string; ipv6?: string }
}

RecordWithTTL

interface RecordWithTTL {
  address: string
  ttl: number
}

MXRecord

interface MXRecord {
  priority: number
  exchange: string
}

SRVRecord

interface SRVRecord {
  priority: number
  weight: number
  port: number
  name: string
}

NAPTRRecord

interface NAPTRRecord {
  flags: string
  service: string
  regexp: string
  replacement: string
  order: number
  preference: number
}

SOARecord

interface SOARecord {
  nsname: string
  hostmaster: string
  serial: number
  refresh: number
  retry: number
  expire: number
  minttl: number
}

CAARecord

interface CAARecord {
  critical: number
  issue?: string
  issuewild?: string
  iodef?: string
  contactemail?: string
  contactphone?: string
}

TLSARecord

interface TLSARecord {
  certUsage: number
  selector: number
  match: number
  data: Buffer
}

bare-dns/promises

promises

promises.AnyRecord

type AnyRecord = | ({ type: 'A' } & RecordWithTTL)
  | ({ type: 'AAAA' } & RecordWithTTL)
  | { type: 'CNAME'; value: string }
  | { type: 'NS'; value: string }
  | { type: 'PTR'; value: string }
  | { type: 'TXT'; entries: string[] }
  | ({ type: 'MX' } & MXRecord)
  | ({ type: 'SRV' } & SRVRecord)
  | ({ type: 'NAPTR' } & NAPTRRecord)
  | ({ type: 'SOA' } & SOARecord)

promises.cancel(): void

promises.constants

promises.constants: {
  readonly type: {
    readonly A: 1
    readonly NS: 2
    readonly CNAME: 5
    readonly SOA: 6
    readonly PTR: 12
    readonly HINFO: 13
    readonly MX: 15
    readonly TXT: 16
    readonly SIG: 24
    readonly AAAA: 28
    readonly SRV: 33
    readonly NAPTR: 35
    readonly OPT: 41
    readonly TLSA: 52
    readonly SVCB: 64
    readonly HTTPS: 65
    readonly ANY: 255
    readonly URI: 256
    readonly CAA: 257
  }
  readonly status: Record<string, number>
}

promises.getServers(): string[]

promises.lookup

promises.lookup(hostname: string, opts?: LookupOptions & { all?: false }): Promise<{ address: string; family: IPFamily | 0 }>

Parameters

ParameterTypeDefaultDescription
hostnamestring——
opts?LookupOptions & { all?: false }——

promises.resolve: DNSPromiseResolver['resolve']

promises.resolve4: DNSPromiseResolver['resolve4']

promises.resolve6: DNSPromiseResolver['resolve6']

promises.resolveAny: DNSPromiseResolver['resolveAny']

promises.resolveCaa: DNSPromiseResolver['resolveCaa']

promises.resolveCname: DNSPromiseResolver['resolveCname']

promises.resolveMx: DNSPromiseResolver['resolveMx']

promises.resolveNaptr: DNSPromiseResolver['resolveNaptr']

promises.resolveNs: DNSPromiseResolver['resolveNs']

promises.resolvePtr: DNSPromiseResolver['resolvePtr']

promises.resolveSoa: DNSPromiseResolver['resolveSoa']

promises.resolveSrv: DNSPromiseResolver['resolveSrv']

promises.resolveTlsa: DNSPromiseResolver['resolveTlsa']

promises.resolveTxt: DNSPromiseResolver['resolveTxt']

promises.reverse: DNSPromiseResolver['reverse']

promises.setLocalAddress(ipv4?: string | null, ipv6?: string | null): void

Parameters

ParameterTypeDefaultDescription
ipv4?string | null——
ipv6?string | null——

promises.setServers(servers: string[]): void

Parameters

ParameterTypeDefaultDescription
serversstring[]——

DNSPromiseResolver

The module exports this class as promises.Resolver, so create one with new promises.Resolver(). DNSPromiseResolver is its name in the type declarations, and promises.DNSPromiseResolver does not exist.

new DNSPromiseResolver(opts?: DNSResolverOptions)

Parameters

ParameterTypeDefaultDescription
opts?DNSResolverOptions——

promises.DNSPromiseResolver.cancel(): void

Aborts every query outstanding on this resolver. Each pending promise is rejected with ECANCELLED.

promises.DNSPromiseResolver.destroy(): void

Cancels every query outstanding on this resolver, so that none is left without an answer, and releases the resources it holds. A query made after this rejects.

DNSPromiseResolver.global: DNSPromiseResolver

promises.DNSPromiseResolver.getServers(): string[]

resolve(hostname: string, rrtype?: 'A' | 'AAAA' | 'CNAME' | 'NS' | 'PTR'): Promise<string[]>

Overloads:

resolve(hostname: string, rrtype?: 'A' | 'AAAA' | 'CNAME' | 'NS' | 'PTR'): Promise<string[]>
resolve(hostname: string, rrtype: 'TXT'): Promise<string[][]>
resolve(hostname: string, rrtype: 'MX'): Promise<MXRecord[]>
resolve(hostname: string, rrtype: 'SRV'): Promise<SRVRecord[]>
resolve(hostname: string, rrtype: 'NAPTR'): Promise<NAPTRRecord[]>
resolve(hostname: string, rrtype: 'SOA'): Promise<SOARecord>
resolve(hostname: string, rrtype: 'CAA'): Promise<CAARecord[]>
resolve(hostname: string, rrtype: 'TLSA'): Promise<TLSARecord[]>
resolve(hostname: string, rrtype: 'ANY'): Promise<AnyRecord[]>

Parameters

ParameterTypeDefaultDescription
hostnamestring——
rrtype?'A' | 'AAAA' | 'CNAME' | 'NS' | 'PTR'——

resolve4(hostname: string, opts?: { ttl?: false }): Promise<string[]>

Overloads:

resolve4(hostname: string, opts?: { ttl?: false }): Promise<string[]>
resolve4(hostname: string, opts: { ttl: true }): Promise<RecordWithTTL[]>

Parameters

ParameterTypeDefaultDescription
hostnamestring——
opts?{ ttl?: false }——

resolve6(hostname: string, opts?: { ttl?: false }): Promise<string[]>

Overloads:

resolve6(hostname: string, opts?: { ttl?: false }): Promise<string[]>
resolve6(hostname: string, opts: { ttl: true }): Promise<RecordWithTTL[]>

Parameters

ParameterTypeDefaultDescription
hostnamestring——
opts?{ ttl?: false }——

resolveAny(hostname: string): Promise<AnyRecord[]>

Parameters

ParameterTypeDefaultDescription
hostnamestring——

resolveCaa(hostname: string): Promise<CAARecord[]>

Parameters

ParameterTypeDefaultDescription
hostnamestring——

resolveCname(hostname: string): Promise<string[]>

Parameters

ParameterTypeDefaultDescription
hostnamestring——

resolveMx(hostname: string): Promise<MXRecord[]>

Parameters

ParameterTypeDefaultDescription
hostnamestring——

resolveNaptr(hostname: string): Promise<NAPTRRecord[]>

Parameters

ParameterTypeDefaultDescription
hostnamestring——

resolveNs(hostname: string): Promise<string[]>

Parameters

ParameterTypeDefaultDescription
hostnamestring——

resolvePtr(hostname: string): Promise<string[]>

Parameters

ParameterTypeDefaultDescription
hostnamestring——

resolveSoa(hostname: string): Promise<SOARecord>

Parameters

ParameterTypeDefaultDescription
hostnamestring——

resolveSrv(hostname: string): Promise<SRVRecord[]>

Parameters

ParameterTypeDefaultDescription
hostnamestring——

resolveTlsa(hostname: string): Promise<TLSARecord[]>

Parameters

ParameterTypeDefaultDescription
hostnamestring——

resolveTxt(hostname: string): Promise<string[][]>

Parameters

ParameterTypeDefaultDescription
hostnamestring——

reverse(ip: string): Promise<string[]>

Resolves the pointer records for ip.

This queries the reverse zone for the address only. Unlike Node.js, the hosts file is not consulted first, so an address that is only named there does not resolve.

Parameters

ParameterTypeDefaultDescription
ipstring——

promises.DNSPromiseResolver.setLocalAddress(ipv4?: string | null, ipv6?: string | null): void

Parameters

ParameterTypeDefaultDescription
ipv4?string | null——
ipv6?string | null——

promises.DNSPromiseResolver.setServers(servers: string[]): void

Parameters

ParameterTypeDefaultDescription
serversstring[]——

DNSError

promises.DNSError.code: string

promises.DNSError.INVALID_IP_ADDRESS(msg?: string): DNSError

Parameters

ParameterTypeDefaultDescription
msg?string——

promises.DNSError.query(status: number, syscall: string, hostname?: string | null): DNSError

Parameters

ParameterTypeDefaultDescription
statusnumber——
syscallstring——
hostname?string | null——

promises.DNSError.RESOLVER_DESTROYED(msg?: string): DNSError

Parameters

ParameterTypeDefaultDescription
msg?string——

promises.DNSError.UNKNOWN_RECORD_TYPE(msg?: string): DNSError

Parameters

ParameterTypeDefaultDescription
msg?string——

promises.DNSError.hostname: string

Present on errors created by DNSError.query() for a named host.

promises.DNSError.name: 'DNSError'

promises.DNSError.syscall: string

Present on errors created by DNSError.query().

Types

promises.RecordWithTTL

interface RecordWithTTL {
  address: string
  ttl: number
}

promises.MXRecord

interface MXRecord {
  priority: number
  exchange: string
}

promises.SRVRecord

interface SRVRecord {
  priority: number
  weight: number
  port: number
  name: string
}

promises.NAPTRRecord

interface NAPTRRecord {
  flags: string
  service: string
  regexp: string
  replacement: string
  order: number
  preference: number
}

promises.SOARecord

interface SOARecord {
  nsname: string
  hostmaster: string
  serial: number
  refresh: number
  retry: number
  expire: number
  minttl: number
}

promises.CAARecord

interface CAARecord {
  critical: number
  issue?: string
  issuewild?: string
  iodef?: string
  contactemail?: string
  contactphone?: string
}

promises.TLSARecord

interface TLSARecord {
  certUsage: number
  selector: number
  match: number
  data: Buffer
}

promises.LookupOptions

interface LookupOptions {
  family?: `IPv${IPFamily}` | IPFamily | 0
  hints?: number
  all?: boolean
}

promises.DNSResolverOptions

interface DNSResolverOptions {
  servers?: string[]
  localAddress?: { ipv4?: string; ipv6?: string }
}

bare-dns/constants

Constants and variables

constants

constants: {
  readonly type: {
    readonly A: 1
    readonly NS: 2
    readonly CNAME: 5
    readonly SOA: 6
    readonly PTR: 12
    readonly HINFO: 13
    readonly MX: 15
    readonly TXT: 16
    readonly SIG: 24
    readonly AAAA: 28
    readonly SRV: 33
    readonly NAPTR: 35
    readonly OPT: 41
    readonly TLSA: 52
    readonly SVCB: 64
    readonly HTTPS: 65
    readonly ANY: 255
    readonly URI: 256
    readonly CAA: 257
  }
  readonly status: Record<string, number>
}

bare-dns/errors

DNSError

require('bare-dns/errors') is the DNSError class itself, so its static methods are called as errors.query(), not errors.DNSError.query(). The headings below name them with the class prefix to match the type declarations.

errors.DNSError.code: string

errors.DNSError.INVALID_IP_ADDRESS(msg?: string): DNSError

Parameters

ParameterTypeDefaultDescription
msg?string——

errors.DNSError.query(status: number, syscall: string, hostname?: string | null): DNSError

Parameters

ParameterTypeDefaultDescription
statusnumber——
syscallstring——
hostname?string | null——

errors.DNSError.RESOLVER_DESTROYED(msg?: string): DNSError

Parameters

ParameterTypeDefaultDescription
msg?string——

errors.DNSError.UNKNOWN_RECORD_TYPE(msg?: string): DNSError

Parameters

ParameterTypeDefaultDescription
msg?string——

errors.DNSError.hostname: string

Present on errors created by DNSError.query() for a named host.

errors.DNSError.name: 'DNSError'

errors.DNSError.syscall: string

Present on errors created by DNSError.query().

See also

Last updated on

Was this helpful?

On this page

Usage
Android
API
dns
dns.AnyRecord
dns.cancel(): void
dns.constants
dns.getServers(): string[]
dns.IPFamily
dns.lookup
dns.RecordType
dns.resolve: DNSResolver['resolve']
dns.resolve4: DNSResolver['resolve4']
dns.resolve6: DNSResolver['resolve6']
dns.resolveAny: DNSResolver['resolveAny']
dns.resolveCaa: DNSResolver['resolveCaa']
dns.resolveCname: DNSResolver['resolveCname']
dns.resolveMx: DNSResolver['resolveMx']
dns.resolveNaptr: DNSResolver['resolveNaptr']
dns.resolveNs: DNSResolver['resolveNs']
dns.resolvePtr: DNSResolver['resolvePtr']
dns.resolveSoa: DNSResolver['resolveSoa']
dns.resolveSrv: DNSResolver['resolveSrv']
dns.resolveTlsa: DNSResolver['resolveTlsa']
dns.resolveTxt: DNSResolver['resolveTxt']
dns.reverse: DNSResolver['reverse']
dns.setLocalAddress(ipv4?: string | null, ipv6?: string | null): void
dns.setServers(servers: string[]): void
DNSResolver
new DNSResolver(opts?: DNSResolverOptions)
DNSResolver.cancel(): void
DNSResolver.destroy(): void
DNSResolver.global: DNSResolver
DNSResolver.getServers(): string[]
resolve(hostname: string, cb: Callback<string[]>): void
resolve4(hostname: string, cb: Callback<string[]>): void
resolve6(hostname: string, cb: Callback<string[]>): void
resolveAny(hostname: string, cb: Callback<AnyRecord[]>): void
resolveCaa(hostname: string, cb: Callback<CAARecord[]>): void
resolveCname(hostname: string, cb: Callback<string[]>): void
resolveMx(hostname: string, cb: Callback<MXRecord[]>): void
resolveNaptr(hostname: string, cb: Callback<NAPTRRecord[]>): void
resolveNs(hostname: string, cb: Callback<string[]>): void
resolvePtr(hostname: string, cb: Callback<string[]>): void
resolveSoa(hostname: string, cb: Callback<SOARecord>): void
resolveSrv(hostname: string, cb: Callback<SRVRecord[]>): void
resolveTlsa(hostname: string, cb: Callback<TLSARecord[]>): void
resolveTxt(hostname: string, cb: Callback<string[][]>): void
reverse(ip: string, cb: Callback<string[]>): void
DNSResolver.setLocalAddress(ipv4?: string | null, ipv6?: string | null): void
DNSResolver.setServers(servers: string[]): void
DNSError
DNSError.code: string
DNSError.INVALID_IP_ADDRESS(msg?: string): DNSError
DNSError.query(status: number, syscall: string, hostname?: string | null): DNSError
DNSError.RESOLVER_DESTROYED(msg?: string): DNSError
DNSError.UNKNOWN_RECORD_TYPE(msg?: string): DNSError
DNSError.hostname: string
DNSError.name: 'DNSError'
DNSError.syscall: string
Types
LookupOptions
DNSResolverOptions
RecordWithTTL
MXRecord
SRVRecord
NAPTRRecord
SOARecord
CAARecord
TLSARecord
bare-dns/promises
promises
promises.AnyRecord
promises.cancel(): void
promises.constants
promises.getServers(): string[]
promises.lookup
promises.resolve: DNSPromiseResolver['resolve']
promises.resolve4: DNSPromiseResolver['resolve4']
promises.resolve6: DNSPromiseResolver['resolve6']
promises.resolveAny: DNSPromiseResolver['resolveAny']
promises.resolveCaa: DNSPromiseResolver['resolveCaa']
promises.resolveCname: DNSPromiseResolver['resolveCname']
promises.resolveMx: DNSPromiseResolver['resolveMx']
promises.resolveNaptr: DNSPromiseResolver['resolveNaptr']
promises.resolveNs: DNSPromiseResolver['resolveNs']
promises.resolvePtr: DNSPromiseResolver['resolvePtr']
promises.resolveSoa: DNSPromiseResolver['resolveSoa']
promises.resolveSrv: DNSPromiseResolver['resolveSrv']
promises.resolveTlsa: DNSPromiseResolver['resolveTlsa']
promises.resolveTxt: DNSPromiseResolver['resolveTxt']
promises.reverse: DNSPromiseResolver['reverse']
promises.setLocalAddress(ipv4?: string | null, ipv6?: string | null): void
promises.setServers(servers: string[]): void
DNSPromiseResolver
new DNSPromiseResolver(opts?: DNSResolverOptions)
promises.DNSPromiseResolver.cancel(): void
promises.DNSPromiseResolver.destroy(): void
DNSPromiseResolver.global: DNSPromiseResolver
promises.DNSPromiseResolver.getServers(): string[]
resolve(hostname: string, rrtype?: 'A' | 'AAAA' | 'CNAME' | 'NS' | 'PTR'): Promise<string[]>
resolve4(hostname: string, opts?: { ttl?: false }): Promise<string[]>
resolve6(hostname: string, opts?: { ttl?: false }): Promise<string[]>
resolveAny(hostname: string): Promise<AnyRecord[]>
resolveCaa(hostname: string): Promise<CAARecord[]>
resolveCname(hostname: string): Promise<string[]>
resolveMx(hostname: string): Promise<MXRecord[]>
resolveNaptr(hostname: string): Promise<NAPTRRecord[]>
resolveNs(hostname: string): Promise<string[]>
resolvePtr(hostname: string): Promise<string[]>
resolveSoa(hostname: string): Promise<SOARecord>
resolveSrv(hostname: string): Promise<SRVRecord[]>
resolveTlsa(hostname: string): Promise<TLSARecord[]>
resolveTxt(hostname: string): Promise<string[][]>
reverse(ip: string): Promise<string[]>
promises.DNSPromiseResolver.setLocalAddress(ipv4?: string | null, ipv6?: string | null): void
promises.DNSPromiseResolver.setServers(servers: string[]): void
DNSError
promises.DNSError.code: string
promises.DNSError.INVALID_IP_ADDRESS(msg?: string): DNSError
promises.DNSError.query(status: number, syscall: string, hostname?: string | null): DNSError
promises.DNSError.RESOLVER_DESTROYED(msg?: string): DNSError
promises.DNSError.UNKNOWN_RECORD_TYPE(msg?: string): DNSError
promises.DNSError.hostname: string
promises.DNSError.name: 'DNSError'
promises.DNSError.syscall: string
Types
promises.RecordWithTTL
promises.MXRecord
promises.SRVRecord
promises.NAPTRRecord
promises.SOARecord
promises.CAARecord
promises.TLSARecord
promises.LookupOptions
promises.DNSResolverOptions
bare-dns/constants
Constants and variables
constants
bare-dns/errors
DNSError
errors.DNSError.code: string
errors.DNSError.INVALID_IP_ADDRESS(msg?: string): DNSError
errors.DNSError.query(status: number, syscall: string, hostname?: string | null): DNSError
errors.DNSError.RESOLVER_DESTROYED(msg?: string): DNSError
errors.DNSError.UNKNOWN_RECORD_TYPE(msg?: string): DNSError
errors.DNSError.hostname: string
errors.DNSError.name: 'DNSError'
errors.DNSError.syscall: string
See also