Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dns-over-http-resolver

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dns-over-http-resolver

DNS over HTTP resolver

  • 1.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
59K
decreased by-12.12%
Maintainers
1
Weekly downloads
 
Created
Source

dns-over-http-resolver

Build Status dependencies Status JavaScript Style Guide

DNS over HTTP resolver

Isomorphic DNS over HTTP resolver using fetch.

API based on Node.js' dns promises API, allowing the native dns module to be used if available when relying on this API.

Install

npm i dns-over-http-resolver

Usage

const DnsOverHttpResolver = require('dns-over-http-resolver')

const dohResolver = new DnsOverHttpResolver(options)

Cloudflare and Google DNS servers are used by default. They can be replaced via the API.

You can also use require('dns').promises in Node.js in lieu of this module.

options

You can provide the following options for the DnsOverHttpResolver:

NameTypeDescriptionDefault
maxCachenumbermaximum number of cached dns records100

API

resolve(hostname, rrType)

Uses the DNS protocol to resolve the given host name into a DNS record.

Parameters
NameTypeDescription
hostnamestringhost name to resolve
[rrType]stringresource record type (default: 'A')
Returns
TypeDescription
Promise<Array<string>>returns a Promise resolving a DNS record according to its type
Example
const DnsOverHttpResolver = require('dns-over-http-resolver')
const resolver = new DnsOverHttpResolver()

const hostname = 'google.com'
const recordType = 'TXT'

const dnsRecord = await resolver.resolve(hostname, recordType)

resolve4(hostname)

Uses the DNS protocol to resolve the given host name into IPv4 addresses.

Parameters
NameTypeDescription
hostnamestringhost name to resolve
Returns
TypeDescription
Promise<Array<string>>returns a Promise resolving IPv4 addresses
Example
const DnsOverHttpResolver = require('dns-over-http-resolver')
const resolver = new DnsOverHttpResolver()

const hostname = 'google.com'

const address = await resolver.resolve4(hostname) // ['216.58.212.142']

resolve6(hostname)

Uses the DNS protocol to resolve the given host name into IPv6 addresses.

Parameters
NameTypeDescription
hostnamestringhost name to resolve
Returns
TypeDescription
Promise<Array<string>>returns a Promise resolving IPv6 addresses
Example
const DnsOverHttpResolver = require('dns-over-http-resolver')
const resolver = new DnsOverHttpResolver()

const hostname = 'google.com'

const address = await resolver.resolve6(hostname) // ['2a00:1450:4001:801::200e']

resolveTxt(hostname)

Uses the DNS protocol to resolve the given host name into a Text Record.

Parameters
NameTypeDescription
hostnamestringhost name to resolve
Returns
TypeDescription
Promise<Array<Array<string>>>returns a Promise resolving a Text Record
Example
const DnsOverHttpResolver = require('dns-over-http-resolver')
const resolver = new DnsOverHttpResolver()

const hostname = 'google.com'

const address = await resolver.resolveTxt(hostname) // [['v=spf1 -all']]

getServers()

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.

Returns
TypeDescription
Array<string>returns array of DNS servers used
Example
const DnsOverHttpResolver = require('dns-over-http-resolver')

const resolver = new DnsOverHttpResolver()
const servers = resolver.getServers()

setServers(servers)

Sets the IP address and port of servers to be used when performing DNS resolution.

Parameters
NameTypeDescription
serversArray<string>Array of RFC 5952 formatted addresses.
Example
const DnsOverHttpResolver = require('dns-over-http-resolver')

const resolver = new DnsOverHttpResolver()
resolver.setServers(['https://cloudflare-dns.com/dns-query'])

Contribute

Feel free to dive in! Open an issue or submit PRs.

License

MIT © Vasco Santos

Keywords

FAQs

Package last updated on 05 Nov 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc