DNSoverHTTPS

DNSoverHTTPS

Request DNS information over HTTPS. The lookup function provides the easiest-to-use defaults.

Constructor

new DNSoverHTTPS(opts)

Create a DNSoverHTTPS instance.
Source:
Parameters:
Name Type Description
opts object Options for all requests.
Name Type Attributes Default Description
userAgent string <optional>
"packageName version" User Agent for HTTP request.
url string <optional>
"https://cloudflare-dns.com/dns-query" Base URL for all HTTP requests.
preferPost boolean <optional>
true Should POST be preferred to Get for DNS-format queries?
contentType string <optional>
"application/dns-udpwireformat" MIME type for POST.
verbose number <optional>
0 How verbose do you want your logging?
verboseStream Writable <optional>
process.stderr Where to write verbose output.
http2 boolean <optional>
false Use http/2 if it is available.

Classes

DNSoverHTTPS

Members

(static) version :string

Source:
Type:
  • string

Methods

(async) getDNS(opts) → {Promise.<(Buffer|object)>}

Get a DNS-format response.
Source:
Parameters:
Name Type Description
opts DOH_LookupOptions Options for the request.
Returns:
Type:
Promise.<(Buffer|object)>
DNS result.

getJSON(opts) → {Promise.<(string|object)>}

Make a HTTPS GET request for JSON DNS.
Source:
Parameters:
Name Type Description
opts object Options for the request.
Name Type Attributes Default Description
name string <optional>
The name to look up.
rrtype string <optional>
"A" The record type to look up.
decode boolean <optional>
true Parse the returned JSON?
dnssec boolean <optional>
false Request DNSSEC records.
Returns:
Type:
Promise.<(string|object)>
DNS result.

lookup(name, optsopt) → {Promise.<(Buffer|string|object)>}

Look up a DNS entry using DNS-over-HTTPS (DoH).
Source:
Parameters:
Name Type Attributes Default Description
name string | DOH_LookupOptions The DNS name to look up, or opts if this is an object.
opts DOH_LookupOptions | string <optional>
{} Options for the request. If a string is given, it will be used as the rrtype.
Returns:
Type:
Promise.<(Buffer|string|object)>
DNS result.