Skip to content

Promises

[<Interface>]
type Promises =
    [<Literal>] ADDRGETNETWORKPARAMS: string = "EADDRGETNETWORKPARAMS"
    [<Literal>] BADFAMILY: string = "EBADFAMILY"
    [<Literal>] BADFLAGS: string = "EBADFLAGS"
    [<Literal>] BADHINTS: string = "EBADHINTS"
    [<Literal>] BADNAME: string = "EBADNAME"
    [<Literal>] BADQUERY: string = "EBADQUERY"
    [<Literal>] BADRESP: string = "EBADRESP"
    [<Literal>] BADSTR: string = "EBADSTR"
    [<Literal>] CANCELLED: string = "ECANCELLED"
    [<Literal>] CONNREFUSED: string = "ECONNREFUSED"
    [<Literal>] DESTRUCTION: string = "EDESTRUCTION"
    [<Literal>] EOF: string = "EOF"
    [<Literal>] FILE: string = "EFILE"
    [<Literal>] FORMERR: string = "EFORMERR"
    [<Literal>] LOADIPHLPAPI: string = "ELOADIPHLPAPI"
    [<Literal>] NODATA: string = "ENODATA"
    [<Literal>] NOMEM: string = "ENOMEM"
    [<Literal>] NONAME: string = "ENONAME"
    [<Literal>] NOTFOUND: string = "ENOTFOUND"
    [<Literal>] NOTIMP: string = "ENOTIMP"
    [<Literal>] NOTINITIALIZED: string = "ENOTINITIALIZED"
    [<Literal>] REFUSED: string = "EREFUSED"
    [<Literal>] SERVFAIL: string = "ESERVFAIL"
    [<Literal>] TIMEOUT: string = "ETIMEOUT"
    abstract member ADDRGETNETWORKPARAMS: string
    abstract member BADFAMILY: string
    abstract member BADFLAGS: string
    abstract member BADHINTS: string
    abstract member BADNAME: string
    abstract member BADQUERY: string
    abstract member BADRESP: string
    abstract member BADSTR: string
    abstract member CANCELLED: string
    abstract member CONNREFUSED: string
    abstract member DESTRUCTION: string
    abstract member EOF: string
    abstract member FILE: string
    abstract member FORMERR: string
    abstract member LOADIPHLPAPI: string
    abstract member NODATA: string
    abstract member NOMEM: string
    abstract member NONAME: string
    abstract member NOTFOUND: string
    abstract member NOTIMP: string
    abstract member NOTINITIALIZED: string
    abstract member REFUSED: string
    abstract member Resolver: ResolverConstructor with get, set
    abstract member SERVFAIL: string
    abstract member TIMEOUT: string
    abstract member getDefaultResultOrder () : Result
    abstract member getServers () : string array
    abstract member lookup (hostname: string) : Promise<LookupAddress>
    abstract member lookup (hostname: string, options: LookupOptions) : Promise<U2<LookupAddress array,LookupAddress>>
    abstract member lookup (hostname: string, options: LookupAllOptions) : Promise<LookupAddress array>
    abstract member lookup (hostname: string, options: LookupOneOptions) : Promise<LookupAddress>
    abstract member lookup (hostname: string, family: float) : Promise<LookupAddress>
    abstract member lookupService (address: string, port: float) : Promise<Item>
    abstract member resolve (hostname: string, rrtype: string) : Promise<U9<string array,string array array,CaaRecord array,MxRecord array,NaptrRecord array,SrvRecord array,TlsaRecord array,AnyRecord array,SoaRecord>>
    abstract member resolve (hostname: string, rrtype: Rrtype) : Promise<string array>
    abstract member resolve (hostname: string) : Promise<string array>
    abstract member resolve4 (hostname: string, options: ResolveOptions) : Promise<U2<string array,RecordWithTtl array>>
    abstract member resolve4 (hostname: string, options: ResolveWithTtlOptions) : Promise<RecordWithTtl array>
    abstract member resolve4 (hostname: string) : Promise<string array>
    abstract member resolve6 (hostname: string, options: ResolveOptions) : Promise<U2<string array,RecordWithTtl array>>
    abstract member resolve6 (hostname: string, options: ResolveWithTtlOptions) : Promise<RecordWithTtl array>
    abstract member resolve6 (hostname: string) : Promise<string array>
    abstract member resolveANY (hostname: string) : Promise<AnyRecord array>
    abstract member resolveAny (hostname: string) : Promise<AnyRecord array>
    abstract member resolveCAA (hostname: string) : Promise<CaaRecord array>
    abstract member resolveCaa (hostname: string) : Promise<CaaRecord array>
    abstract member resolveCname (hostname: string) : Promise<string array>
    abstract member resolveMX (hostname: string) : Promise<MxRecord array>
    abstract member resolveMx (hostname: string) : Promise<MxRecord array>
    abstract member resolveNAPTR (hostname: string) : Promise<NaptrRecord array>
    abstract member resolveNaptr (hostname: string) : Promise<NaptrRecord array>
    abstract member resolveNs (hostname: string) : Promise<string array>
    abstract member resolvePtr (hostname: string) : Promise<string array>
    abstract member resolveSOA (hostname: string) : Promise<SoaRecord>
    abstract member resolveSRV (hostname: string) : Promise<SrvRecord array>
    abstract member resolveSoa (hostname: string) : Promise<SoaRecord>
    abstract member resolveSrv (hostname: string) : Promise<SrvRecord array>
    abstract member resolveTLSA (hostname: string) : Promise<TlsaRecord array>
    abstract member resolveTXT (hostname: string) : Promise<string array array>
    abstract member resolveTlsa (hostname: string) : Promise<TlsaRecord array>
    abstract member resolveTxt (hostname: string) : Promise<string array array>
    abstract member reverse (ip: string) : Promise<string array>
    abstract member setDefaultResultOrder (order: Order) : unit
    abstract member setServers (servers: string array) : unit
AssemblyXantham.Fable.Node

node:dns/promises

Declared inside

ExportsThe package's value exports, each bound to its import
GetDefaultResultOrder
LookupService
ResolverAn independent resolver for DNS requests

Functions and values

[<Literal>] ADDRGETNETWORKPARAMS: string = "EADDRGETNETWORKPARAMS"

TypeScript type: "EADDRGETNETWORKPARAMS"

[<Literal>] BADFAMILY: string = "EBADFAMILY"

TypeScript type: "EBADFAMILY"

[<Literal>] BADFLAGS: string = "EBADFLAGS"

TypeScript type: "EBADFLAGS"

[<Literal>] BADHINTS: string = "EBADHINTS"

TypeScript type: "EBADHINTS"

[<Literal>] BADNAME: string = "EBADNAME"

TypeScript type: "EBADNAME"

[<Literal>] BADQUERY: string = "EBADQUERY"

TypeScript type: "EBADQUERY"

[<Literal>] BADRESP: string = "EBADRESP"

TypeScript type: "EBADRESP"

[<Literal>] BADSTR: string = "EBADSTR"

TypeScript type: "EBADSTR"

[<Literal>] CANCELLED: string = "ECANCELLED"

TypeScript type: "ECANCELLED"

[<Literal>] CONNREFUSED: string = "ECONNREFUSED"

TypeScript type: "ECONNREFUSED"

[<Literal>] DESTRUCTION: string = "EDESTRUCTION"

TypeScript type: "EDESTRUCTION"

[<Literal>] EOF: string = "EOF"

TypeScript type: "EOF"

[<Literal>] FILE: string = "EFILE"

TypeScript type: "EFILE"

[<Literal>] FORMERR: string = "EFORMERR"

TypeScript type: "EFORMERR"

[<Literal>] LOADIPHLPAPI: string = "ELOADIPHLPAPI"

TypeScript type: "ELOADIPHLPAPI"

[<Literal>] NODATA: string = "ENODATA"

TypeScript type: "ENODATA"

[<Literal>] NOMEM: string = "ENOMEM"

TypeScript type: "ENOMEM"

[<Literal>] NONAME: string = "ENONAME"

TypeScript type: "ENONAME"

[<Literal>] NOTFOUND: string = "ENOTFOUND"

TypeScript type: "ENOTFOUND"

[<Literal>] NOTIMP: string = "ENOTIMP"

TypeScript type: "ENOTIMP"

[<Literal>] NOTINITIALIZED: string = "ENOTINITIALIZED"

TypeScript type: "ENOTINITIALIZED"

[<Literal>] REFUSED: string = "EREFUSED"

TypeScript type: "EREFUSED"

[<Literal>] SERVFAIL: string = "ESERVFAIL"

TypeScript type: "ESERVFAIL"

[<Literal>] TIMEOUT: string = "ETIMEOUT"

TypeScript type: "ETIMEOUT"

Properties

abstract member ADDRGETNETWORKPARAMS: string

TypeScript type: "EADDRGETNETWORKPARAMS"

abstract member BADFAMILY: string

TypeScript type: "EBADFAMILY"

abstract member BADFLAGS: string

TypeScript type: "EBADFLAGS"

abstract member BADHINTS: string

TypeScript type: "EBADHINTS"

abstract member BADNAME: string

TypeScript type: "EBADNAME"

abstract member BADQUERY: string

TypeScript type: "EBADQUERY"

abstract member BADRESP: string

TypeScript type: "EBADRESP"

abstract member BADSTR: string

TypeScript type: "EBADSTR"

abstract member CANCELLED: string

TypeScript type: "ECANCELLED"

abstract member CONNREFUSED: string

TypeScript type: "ECONNREFUSED"

abstract member DESTRUCTION: string

TypeScript type: "EDESTRUCTION"

abstract member EOF: string

TypeScript type: "EOF"

abstract member FILE: string

TypeScript type: "EFILE"

abstract member FORMERR: string

TypeScript type: "EFORMERR"

abstract member LOADIPHLPAPI: string

TypeScript type: "ELOADIPHLPAPI"

abstract member NODATA: string

TypeScript type: "ENODATA"

abstract member NOMEM: string

TypeScript type: "ENOMEM"

abstract member NONAME: string

TypeScript type: "ENONAME"

abstract member NOTFOUND: string

TypeScript type: "ENOTFOUND"

abstract member NOTIMP: string

TypeScript type: "ENOTIMP"

abstract member NOTINITIALIZED: string

TypeScript type: "ENOTINITIALIZED"

abstract member REFUSED: string

TypeScript type: "EREFUSED"

abstract member Resolver: ResolverConstructor with get, set

An independent resolver for DNS requests.

Creating a new resolver uses the default server settings. Setting the servers used for a resolver using resolver.setServers() does not affect other resolvers:

import { promises } from 'node:dns';
const resolver = new promises.Resolver();
resolver.setServers(['4.4.4.4']);

// This request will use the server at 4.4.4.4, independent of global settings.
resolver.resolve4('example.org').then((addresses) => {
// ...
});

// Alternatively, the same code can be written using async-await style.
(async function() {
const addresses = await resolver.resolve4('example.org');
})();

The following methods from the dnsPromises API are available:

  • resolver.getServers()
  • resolver.resolve()
  • resolver.resolve4()
  • resolver.resolve6()
  • resolver.resolveAny()
  • resolver.resolveCaa()
  • resolver.resolveCname()
  • resolver.resolveMx()
  • resolver.resolveNaptr()
  • resolver.resolveNs()
  • resolver.resolvePtr()
  • resolver.resolveSoa()
  • resolver.resolveSrv()
  • resolver.resolveTxt()
  • resolver.reverse()
  • resolver.setServers()

@since v10.6.0

abstract member SERVFAIL: string

TypeScript type: "ESERVFAIL"

abstract member TIMEOUT: string

TypeScript type: "ETIMEOUT"

Methods

abstract member getDefaultResultOrder () : Result

Get the default value for verbatim in lookup and dnsPromises.lookup(). The value could be:

  • ipv4first: for verbatim defaulting to false.
  • verbatim: for verbatim defaulting to true.

@since v20.1.0

abstract member getServers () : string array

Returns an array of IP address strings, formatted according to RFC 5952, that are currently configured for DNS resolution. A string will include a port section if a custom port is used.

[
'4.4.4.4',
'2001:4860:4860::8888',
'4.4.4.4:1053',
'[2001:4860:4860::8888]:1053',
]

@since v10.6.0

abstract member lookup (hostname: string) : Promise<LookupAddress>

Resolves a host name (e.g. 'nodejs.org') into the first found A (IPv4) or AAAA (IPv6) record. All option properties are optional. If options is an integer, then it must be 4 or 6 โ€“ if options is not provided, then IPv4 and IPv6 addresses are both returned if found.

With the all option set to true, the Promise is resolved with addresses being an array of objects with the properties address and family.

On error, the Promise is rejected with an Error object, where err.code is the error code. Keep in mind that err.code will be set to 'ENOTFOUND' not only when the host name does not exist but also when the lookup fails in other ways such as no available file descriptors.

dnsPromises.lookup() does not necessarily have anything to do with the DNS protocol. The implementation uses an operating system facility that can associate names with addresses and vice versa. This implementation can have subtle but important consequences on the behavior of any Node.js program. Please take some time to consult the Implementation considerations section before using dnsPromises.lookup().

Example usage:

import dns from 'node:dns';
const dnsPromises = dns.promises;
const options = {
family: 6,
hints: dns.ADDRCONFIG | dns.V4MAPPED,
};

dnsPromises.lookup('example.com', options).then((result) => {
console.log('address: %j family: IPv%s', result.address, result.family);
// address: "2606:2800:220:1:248:1893:25c8:1946" family: IPv6
});

// When options.all is true, the result will be an Array.
options.all = true;
dnsPromises.lookup('example.com', options).then((result) => {
console.log('addresses: %j', result);
// addresses: [{"address":"2606:2800:220:1:248:1893:25c8:1946","family":6}]
});

@since v10.6.0

abstract member lookup (hostname: string, options: LookupOptions) : Promise<U2<LookupAddress array,LookupAddress>>

Resolves a host name (e.g. 'nodejs.org') into the first found A (IPv4) or AAAA (IPv6) record. All option properties are optional. If options is an integer, then it must be 4 or 6 โ€“ if options is not provided, then IPv4 and IPv6 addresses are both returned if found.

With the all option set to true, the Promise is resolved with addresses being an array of objects with the properties address and family.

On error, the Promise is rejected with an Error object, where err.code is the error code. Keep in mind that err.code will be set to 'ENOTFOUND' not only when the host name does not exist but also when the lookup fails in other ways such as no available file descriptors.

dnsPromises.lookup() does not necessarily have anything to do with the DNS protocol. The implementation uses an operating system facility that can associate names with addresses and vice versa. This implementation can have subtle but important consequences on the behavior of any Node.js program. Please take some time to consult the Implementation considerations section before using dnsPromises.lookup().

Example usage:

import dns from 'node:dns';
const dnsPromises = dns.promises;
const options = {
family: 6,
hints: dns.ADDRCONFIG | dns.V4MAPPED,
};

dnsPromises.lookup('example.com', options).then((result) => {
console.log('address: %j family: IPv%s', result.address, result.family);
// address: "2606:2800:220:1:248:1893:25c8:1946" family: IPv6
});

// When options.all is true, the result will be an Array.
options.all = true;
dnsPromises.lookup('example.com', options).then((result) => {
console.log('addresses: %j', result);
// addresses: [{"address":"2606:2800:220:1:248:1893:25c8:1946","family":6}]
});

@since v10.6.0

abstract member lookup (hostname: string, options: LookupAllOptions) : Promise<LookupAddress array>

Resolves a host name (e.g. 'nodejs.org') into the first found A (IPv4) or AAAA (IPv6) record. All option properties are optional. If options is an integer, then it must be 4 or 6 โ€“ if options is not provided, then IPv4 and IPv6 addresses are both returned if found.

With the all option set to true, the Promise is resolved with addresses being an array of objects with the properties address and family.

On error, the Promise is rejected with an Error object, where err.code is the error code. Keep in mind that err.code will be set to 'ENOTFOUND' not only when the host name does not exist but also when the lookup fails in other ways such as no available file descriptors.

dnsPromises.lookup() does not necessarily have anything to do with the DNS protocol. The implementation uses an operating system facility that can associate names with addresses and vice versa. This implementation can have subtle but important consequences on the behavior of any Node.js program. Please take some time to consult the Implementation considerations section before using dnsPromises.lookup().

Example usage:

import dns from 'node:dns';
const dnsPromises = dns.promises;
const options = {
family: 6,
hints: dns.ADDRCONFIG | dns.V4MAPPED,
};

dnsPromises.lookup('example.com', options).then((result) => {
console.log('address: %j family: IPv%s', result.address, result.family);
// address: "2606:2800:220:1:248:1893:25c8:1946" family: IPv6
});

// When options.all is true, the result will be an Array.
options.all = true;
dnsPromises.lookup('example.com', options).then((result) => {
console.log('addresses: %j', result);
// addresses: [{"address":"2606:2800:220:1:248:1893:25c8:1946","family":6}]
});

@since v10.6.0

abstract member lookup (hostname: string, options: LookupOneOptions) : Promise<LookupAddress>

Resolves a host name (e.g. 'nodejs.org') into the first found A (IPv4) or AAAA (IPv6) record. All option properties are optional. If options is an integer, then it must be 4 or 6 โ€“ if options is not provided, then IPv4 and IPv6 addresses are both returned if found.

With the all option set to true, the Promise is resolved with addresses being an array of objects with the properties address and family.

On error, the Promise is rejected with an Error object, where err.code is the error code. Keep in mind that err.code will be set to 'ENOTFOUND' not only when the host name does not exist but also when the lookup fails in other ways such as no available file descriptors.

dnsPromises.lookup() does not necessarily have anything to do with the DNS protocol. The implementation uses an operating system facility that can associate names with addresses and vice versa. This implementation can have subtle but important consequences on the behavior of any Node.js program. Please take some time to consult the Implementation considerations section before using dnsPromises.lookup().

Example usage:

import dns from 'node:dns';
const dnsPromises = dns.promises;
const options = {
family: 6,
hints: dns.ADDRCONFIG | dns.V4MAPPED,
};

dnsPromises.lookup('example.com', options).then((result) => {
console.log('address: %j family: IPv%s', result.address, result.family);
// address: "2606:2800:220:1:248:1893:25c8:1946" family: IPv6
});

// When options.all is true, the result will be an Array.
options.all = true;
dnsPromises.lookup('example.com', options).then((result) => {
console.log('addresses: %j', result);
// addresses: [{"address":"2606:2800:220:1:248:1893:25c8:1946","family":6}]
});

@since v10.6.0

abstract member lookup (hostname: string, family: float) : Promise<LookupAddress>

Resolves a host name (e.g. 'nodejs.org') into the first found A (IPv4) or AAAA (IPv6) record. All option properties are optional. If options is an integer, then it must be 4 or 6 โ€“ if options is not provided, then IPv4 and IPv6 addresses are both returned if found.

With the all option set to true, the Promise is resolved with addresses being an array of objects with the properties address and family.

On error, the Promise is rejected with an Error object, where err.code is the error code. Keep in mind that err.code will be set to 'ENOTFOUND' not only when the host name does not exist but also when the lookup fails in other ways such as no available file descriptors.

dnsPromises.lookup() does not necessarily have anything to do with the DNS protocol. The implementation uses an operating system facility that can associate names with addresses and vice versa. This implementation can have subtle but important consequences on the behavior of any Node.js program. Please take some time to consult the Implementation considerations section before using dnsPromises.lookup().

Example usage:

import dns from 'node:dns';
const dnsPromises = dns.promises;
const options = {
family: 6,
hints: dns.ADDRCONFIG | dns.V4MAPPED,
};

dnsPromises.lookup('example.com', options).then((result) => {
console.log('address: %j family: IPv%s', result.address, result.family);
// address: "2606:2800:220:1:248:1893:25c8:1946" family: IPv6
});

// When options.all is true, the result will be an Array.
options.all = true;
dnsPromises.lookup('example.com', options).then((result) => {
console.log('addresses: %j', result);
// addresses: [{"address":"2606:2800:220:1:248:1893:25c8:1946","family":6}]
});

@since v10.6.0

abstract member lookupService (address: string, port: float) : Promise<Item>

Resolves the given address and port into a host name and service using the operating system's underlying getnameinfo implementation.

If address is not a valid IP address, a TypeError will be thrown. The port will be coerced to a number. If it is not a legal port, a TypeError will be thrown.

On error, the Promise is rejected with an Error object, where err.code is the error code.

import dnsPromises from 'node:dns';
dnsPromises.lookupService('127.0.0.1', 22).then((result) => {
console.log(result.hostname, result.service);
// Prints: localhost ssh
});

@since v10.6.0

abstract member resolve (hostname: string, rrtype: string) : Promise<U9<string array,string array array,CaaRecord array,MxRecord array,NaptrRecord array,SrvRecord array,TlsaRecord array,AnyRecord array,SoaRecord>>

Uses the DNS protocol to resolve a host name (e.g. 'nodejs.org') into an array of the resource records. When successful, the Promise is resolved with an array of resource records. The type and structure of individual results vary based on rrtype:

On error, the Promise is rejected with an Error object, where err.code is one of the DNS error codes.

@since v10.6.0

Parameter
hostnameHost name to resolve.
rrtypeResource record type.
abstract member resolve (hostname: string, rrtype: Rrtype) : Promise<string array>

Uses the DNS protocol to resolve a host name (e.g. 'nodejs.org') into an array of the resource records. When successful, the Promise is resolved with an array of resource records. The type and structure of individual results vary based on rrtype:

On error, the Promise is rejected with an Error object, where err.code is one of the DNS error codes.

@since v10.6.0

Parameter
hostnameHost name to resolve.
rrtypeResource record type.
abstract member resolve (hostname: string) : Promise<string array>

Uses the DNS protocol to resolve a host name (e.g. 'nodejs.org') into an array of the resource records. When successful, the Promise is resolved with an array of resource records. The type and structure of individual results vary based on rrtype:

On error, the Promise is rejected with an Error object, where err.code is one of the DNS error codes.

@since v10.6.0

Parameter
hostnameHost name to resolve.
rrtypeResource record type.
abstract member resolve4 (hostname: string, options: ResolveOptions) : Promise<U2<string array,RecordWithTtl array>>

Uses the DNS protocol to resolve IPv4 addresses (A records) for the hostname. On success, the Promise is resolved with an array of IPv4 addresses (e.g. ['74.125.79.104', '74.125.79.105', '74.125.79.106']).

@since v10.6.0

Parameter
hostnameHost name to resolve.
abstract member resolve4 (hostname: string, options: ResolveWithTtlOptions) : Promise<RecordWithTtl array>

Uses the DNS protocol to resolve IPv4 addresses (A records) for the hostname. On success, the Promise is resolved with an array of IPv4 addresses (e.g. ['74.125.79.104', '74.125.79.105', '74.125.79.106']).

@since v10.6.0

Parameter
hostnameHost name to resolve.
abstract member resolve4 (hostname: string) : Promise<string array>

Uses the DNS protocol to resolve IPv4 addresses (A records) for the hostname. On success, the Promise is resolved with an array of IPv4 addresses (e.g. ['74.125.79.104', '74.125.79.105', '74.125.79.106']).

@since v10.6.0

Parameter
hostnameHost name to resolve.
abstract member resolve6 (hostname: string, options: ResolveOptions) : Promise<U2<string array,RecordWithTtl array>>

Uses the DNS protocol to resolve IPv6 addresses (AAAA records) for the hostname. On success, the Promise is resolved with an array of IPv6 addresses.

@since v10.6.0

Parameter
hostnameHost name to resolve.
abstract member resolve6 (hostname: string, options: ResolveWithTtlOptions) : Promise<RecordWithTtl array>

Uses the DNS protocol to resolve IPv6 addresses (AAAA records) for the hostname. On success, the Promise is resolved with an array of IPv6 addresses.

@since v10.6.0

Parameter
hostnameHost name to resolve.
abstract member resolve6 (hostname: string) : Promise<string array>

Uses the DNS protocol to resolve IPv6 addresses (AAAA records) for the hostname. On success, the Promise is resolved with an array of IPv6 addresses.

@since v10.6.0

Parameter
hostnameHost name to resolve.
abstract member resolveANY (hostname: string) : Promise<AnyRecord array>
function resolve(hostname: string, rrtype: "ANY"): Promise<AnyRecord[]>

@since v10.6.0

Parameter
hostnameHost name to resolve.
abstract member resolveAny (hostname: string) : Promise<AnyRecord array>

Uses the DNS protocol to resolve all records (also known as ANY or * query). On success, the Promise is resolved with 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 result object:

[ { 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 } ]

@since v10.6.0

abstract member resolveCAA (hostname: string) : Promise<CaaRecord array>
function resolve(hostname: string, rrtype: "CAA"): Promise<CaaRecord[]>

@since v10.6.0

Parameter
hostnameHost name to resolve.
abstract member resolveCaa (hostname: string) : Promise<CaaRecord array>

Uses the DNS protocol to resolve CAA records for the hostname. On success, the Promise is resolved with an array of objects containing available certification authority authorization records available for the hostname (e.g. [{critical: 0, iodef: 'mailto:pki@example.com'},{critical: 128, issue: 'pki.example.com'}]).

@since v15.0.0, v14.17.0

abstract member resolveCname (hostname: string) : Promise<string array>

Uses the DNS protocol to resolve CNAME records for the hostname. On success, the Promise is resolved with an array of canonical name records available for the hostname (e.g. ['bar.example.com']).

@since v10.6.0

abstract member resolveMX (hostname: string) : Promise<MxRecord array>
function resolve(hostname: string, rrtype: "MX"): Promise<MxRecord[]>

@since v10.6.0

Parameter
hostnameHost name to resolve.
abstract member resolveMx (hostname: string) : Promise<MxRecord array>

Uses the DNS protocol to resolve mail exchange records (MX records) for the hostname. On success, the Promise is resolved with an array of objects containing both a priority and exchange property (e.g.[{priority: 10, exchange: 'mx.example.com'}, ...]).

@since v10.6.0

abstract member resolveNAPTR (hostname: string) : Promise<NaptrRecord array>
function resolve(hostname: string, rrtype: "NAPTR"): Promise<NaptrRecord[]>

@since v10.6.0

Parameter
hostnameHost name to resolve.
abstract member resolveNaptr (hostname: string) : Promise<NaptrRecord array>

Uses the DNS protocol to resolve regular expression-based records (NAPTR records) for the hostname. On success, the Promise is resolved with an array of objects with the following properties:

  • flags
  • service
  • regexp
  • replacement
  • order
  • preference
{
flags: 's',
service: 'SIP+D2U',
regexp: '',
replacement: '_sip._udp.example.com',
order: 30,
preference: 100
}

@since v10.6.0

abstract member resolveNs (hostname: string) : Promise<string array>

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 server records available for hostname (e.g.['ns1.example.com', 'ns2.example.com']).

@since v10.6.0

abstract member resolvePtr (hostname: string) : Promise<string array>

Uses the DNS protocol to resolve pointer records (PTR records) for the hostname. On success, the Promise is resolved with an array of strings containing the reply records.

@since v10.6.0

abstract member resolveSOA (hostname: string) : Promise<SoaRecord>
function resolve(hostname: string, rrtype: "SOA"): Promise<SoaRecord>

@since v10.6.0

Parameter
hostnameHost name to resolve.
abstract member resolveSRV (hostname: string) : Promise<SrvRecord array>
function resolve(hostname: string, rrtype: "SRV"): Promise<SrvRecord[]>

@since v10.6.0

Parameter
hostnameHost name to resolve.
abstract member resolveSoa (hostname: string) : Promise<SoaRecord>

Uses the DNS protocol to resolve a start of authority record (SOA record) for the hostname. On success, the Promise is resolved with an object with the following properties:

  • nsname
  • hostmaster
  • serial
  • refresh
  • retry
  • expire
  • minttl
{
nsname: 'ns.example.com',
hostmaster: 'root.example.com',
serial: 2013101809,
refresh: 10000,
retry: 2400,
expire: 604800,
minttl: 3600
}

@since v10.6.0

abstract member resolveSrv (hostname: string) : Promise<SrvRecord array>

Uses the DNS protocol to resolve service records (SRV records) for the hostname. On success, the Promise is resolved with an array of objects with the following properties:

  • priority
  • weight
  • port
  • name
{
priority: 10,
weight: 5,
port: 21223,
name: 'service.example.com'
}

@since v10.6.0

abstract member resolveTLSA (hostname: string) : Promise<TlsaRecord array>
function resolve(hostname: string, rrtype: "TLSA"): Promise<TlsaRecord[]>

@since v10.6.0

Parameter
hostnameHost name to resolve.
abstract member resolveTXT (hostname: string) : Promise<string array array>
function resolve(hostname: string, rrtype: "TXT"): Promise<string[][]>

@since v10.6.0

Parameter
hostnameHost name to resolve.
abstract member resolveTlsa (hostname: string) : Promise<TlsaRecord array>

Uses the DNS protocol to resolve certificate associations (TLSA records) for the hostname. On success, the Promise is resolved with an array of objectsAdd commentMore actions with these properties:

  • certUsage
  • selector
  • match
  • data
{
certUsage: 3,
selector: 1,
match: 1,
data: [ArrayBuffer]
}

@since v22.15.0

abstract member resolveTxt (hostname: string) : Promise<string array array>

Uses the DNS protocol to resolve text queries (TXT records) for the hostname. On success, the Promise is resolved with 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.

@since v10.6.0

abstract member reverse (ip: string) : Promise<string array>

Performs a reverse DNS query that resolves an IPv4 or IPv6 address to an array of host names.

On error, the Promise is rejected with an Error object, where err.code is one of the DNS error codes.

@since v10.6.0

abstract member setDefaultResultOrder (order: Order) : unit

Set the default value of order in dns.lookup() and {@link lookup}. The value could be:

  • ipv4first: sets default order to ipv4first.
  • ipv6first: sets default order to ipv6first.
  • verbatim: sets default order to verbatim.

The default is verbatim and dnsPromises.setDefaultResultOrder() have higher priority than --dns-result-order. When using worker threads, dnsPromises.setDefaultResultOrder() from the main thread won't affect the default dns orders in workers.

@since v16.4.0, v14.18.0

Parameter
ordermust be 'ipv4first', 'ipv6first' or 'verbatim'.
abstract member setServers (servers: string array) : unit

Sets the IP address and port of servers to be used when performing DNS resolution. The servers argument is an array of RFC 5952 formatted addresses. If the port is the IANA default DNS port (53) it can be omitted.

dnsPromises.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 dnsPromises.setServers() method must not be called while a DNS query is in progress.

This method works much like resolve.conf. 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.

@since v10.6.0

Parameter
serversarray of RFC 5952 formatted addresses