A (multi) DNS-over-HTTPS resolver for Node.js

Overview

doh-resolver

A DNS-over-HTTPS resolver for Node.js.

Last version Coverage Status NPM Status

Install

$ npm install doh-resolver --save

Usage

It can be used as dns.resolve4 and/or dns.resolve6 drop-in replacement:

const DoHResolver = require('doh-resolver')
const resolver = new DoHResolver({ servers: ['1.1.1.1', '8.8.8.8'] })

resolver.resolve4('example.com', (error, addresses) => {
  if (error) throw error
  // Handle the result
})

When you specify more than one server, the result will be the fastest HTTP request into resolve.

Customize the request using your favorite HTTP client:

const DoHResolver = require('doh-resolver')
const { promisify } = require('util')

const resolver = new DoHResolver({
  servers: ['1.1.1.1', '8.8.8.8'],
  get: promisify(require('simple-get'))
})

Combine it with cacheable-lookup for caching lookups respecting TTL:

const CacheableLookup = require('cacheable-lookup')
const DoHResolver = require('doh-resolver')
const https = require('https')

const resolver = new DoHResolver({
  servers: ['1.1.1.1', '8.8.8.8'],
  onError: cb => cb(null, [])
})

const cacheable = new CacheableLookup({ resolver })

https.get('https://example.com', { lookup: cacheable.lookup }, response => {
  // Handle the response here
})

You can store the result via keyv to maximize cache HIT:

const CacheableLookup = require('cacheable-lookup')
const DoHResolver = require('doh-resolver')
const KeyvMulti = require('@keyvhq/multi')
const KeyvRedis = require('@keyvhq/redis')
const Keyv = require('@keyvhq/core')
const https = require('https')

const cache = new Keyv({
  store: new KeyvMulti({
    local: new Map(),
    remote: new KeyvRedis()
  })
})

const resolver = new DoHResolver({
  servers: ['1.1.1.1', '8.8.8.8'],
  onError: cb => cb(null, [])
})

const cacheable = new CacheableLookup({ resolver, cache })

https.get('https://example.com', { lookup: cacheable.lookup }, response => {
  // Handle the response here
})

If you want to debug timings, pass DEBUG=doh-resolver* as environment variable.

License

doh-resolver © Kiko Beats, released under the MIT License.
Authored and maintained by Kiko Beats with help from contributors.

kikobeats.com · GitHub Kiko Beats · Twitter @Kikobeats

Comments
  • build(deps-dev): bump cacheable-lookup from 6.1.0 to 7.0.0

    build(deps-dev): bump cacheable-lookup from 6.1.0 to 7.0.0

    Bumps cacheable-lookup from 6.1.0 to 7.0.0.

    Release notes

    Sourced from cacheable-lookup's releases.

    v7.0.0

    Breaking

    • Require Node.js 14 (#69) 08a6478
    • This package is now pure ESM. Please read this.

    Improvements

    • Add stats for query and cache requests (#65) ab8d286

    https://github.com/szmarczak/cacheable-lookup/compare/v6.1.0...v7.0.0

    Commits
    Maintainer changes

    This version was pushed to npm by sindresorhus, a new releaser for cacheable-lookup since your current version.


    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies javascript 
    opened by dependabot[bot] 2
  • build(deps-dev): bump got from 11.8.5 to 12.3.0

    build(deps-dev): bump got from 11.8.5 to 12.3.0

    Bumps got from 11.8.5 to 12.3.0.

    Release notes

    Sourced from got's releases.

    v12.3.0

    • Add .off() method for events (#2092) 88056be

    https://github.com/sindresorhus/got/compare/v12.2.0...v12.3.0

    v12.2.0

    https://github.com/sindresorhus/got/compare/v12.1.0...v12.2.0

    v12.1.0

    Improvements

    Fixes

    https://github.com/sindresorhus/got/compare/v12.0.4...v12.1.0

    v12.0.4

    • Remove stream lock - unreliable since Node 17.3.0 bb8eca924c338ca12d5b90d6a26aa28dbddb42ee

    v12.0.3

    • Allow more types in the json option (#2015) eb045bf

    https://github.com/sindresorhus/got/compare/v12.0.2...v12.0.3

    v12.0.2

    • Fix encoding option with {responseType: 'json'} (#1996) 0703318

    https://github.com/sindresorhus/got/compare/v12.0.1...v12.0.2

    v12.0.1

    • Fix nock compatibility (#1959) bf39d2c
    • Fix missing export of Request TypeScript type (#1940) 0f9f2b8

    https://github.com/sindresorhus/got/compare/v12.0.0...v12.0.1

    v12.0.0

    Introducing Got v12.0.0 :tada:

    Long time no see! The latest Got version (v11.8.2) was released just in February ❄️ We have been working hard on squashing bugs and improving overall experience.

    ... (truncated)

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies javascript 
    opened by dependabot[bot] 2
  • build(deps-dev): bump got from 11.8.5 to 12.2.0

    build(deps-dev): bump got from 11.8.5 to 12.2.0

    Bumps got from 11.8.5 to 12.2.0.

    Release notes

    Sourced from got's releases.

    v12.2.0

    https://github.com/sindresorhus/got/compare/v12.1.0...v12.2.0

    v12.1.0

    Improvements

    Fixes

    https://github.com/sindresorhus/got/compare/v12.0.4...v12.1.0

    v12.0.4

    • Remove stream lock - unreliable since Node 17.3.0 bb8eca924c338ca12d5b90d6a26aa28dbddb42ee

    v12.0.3

    • Allow more types in the json option (#2015) eb045bf

    https://github.com/sindresorhus/got/compare/v12.0.2...v12.0.3

    v12.0.2

    • Fix encoding option with {responseType: 'json'} (#1996) 0703318

    https://github.com/sindresorhus/got/compare/v12.0.1...v12.0.2

    v12.0.1

    • Fix nock compatibility (#1959) bf39d2c
    • Fix missing export of Request TypeScript type (#1940) 0f9f2b8

    https://github.com/sindresorhus/got/compare/v12.0.0...v12.0.1

    v12.0.0

    Introducing Got v12.0.0 :tada:

    Long time no see! The latest Got version (v11.8.2) was released just in February ❄️ We have been working hard on squashing bugs and improving overall experience.

    If you find Got useful, you might want to sponsor the Got maintainers.

    This package is now pure ESM

    Please read this. Also see sindresorhus/got#1789.

    ... (truncated)

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies javascript 
    opened by dependabot[bot] 1
  • build(deps): bump time-span from 4.0.0 to 5.1.0

    build(deps): bump time-span from 4.0.0 to 5.1.0

    Bumps time-span from 4.0.0 to 5.1.0.

    Release notes

    Sourced from time-span's releases.

    v5.1.0

    • Add browser support (#9) dc45287

    https://github.com/sindresorhus/time-span/compare/v5.0.0...v5.1.0

    v5.0.0

    Breaking

    • Require Node.js 12 00dc535
    • This package is now pure ESM. Please read this.
    • end.nanoseconds() now returns a bigint instead of a number

    https://github.com/sindresorhus/time-span/compare/v4.0.0...v5.0.0

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies javascript 
    opened by dependabot[bot] 1
  • build(deps-dev): bump got from 11.8.5 to 12.1.0

    build(deps-dev): bump got from 11.8.5 to 12.1.0

    Bumps got from 11.8.5 to 12.1.0.

    Release notes

    Sourced from got's releases.

    v12.1.0

    Improvements

    Fixes

    https://github.com/sindresorhus/got/compare/v12.0.4...v12.1.0

    v12.0.4

    • Remove stream lock - unreliable since Node 17.3.0 bb8eca924c338ca12d5b90d6a26aa28dbddb42ee

    v12.0.3

    • Allow more types in the json option (#2015) eb045bf

    https://github.com/sindresorhus/got/compare/v12.0.2...v12.0.3

    v12.0.2

    • Fix encoding option with {responseType: 'json'} (#1996) 0703318

    https://github.com/sindresorhus/got/compare/v12.0.1...v12.0.2

    v12.0.1

    • Fix nock compatibility (#1959) bf39d2c
    • Fix missing export of Request TypeScript type (#1940) 0f9f2b8

    https://github.com/sindresorhus/got/compare/v12.0.0...v12.0.1

    v12.0.0

    Introducing Got v12.0.0 :tada:

    Long time no see! The latest Got version (v11.8.2) was released just in February ❄️ We have been working hard on squashing bugs and improving overall experience.

    If you find Got useful, you might want to sponsor the Got maintainers.

    This package is now pure ESM

    Please read this. Also see sindresorhus/got#1789.

    • Please don't open issues about [ERR_REQUIRE_ESM] and Must use import to load ES Module errors. This is a problem with your setup, not Got.
    • Please don't open issues about using Got with Jest. Jest does not fully support ESM.
    • Pretty much any problem with loading this package is a problem with your bundler, test framework, etc, not Got.
    • If you use TypeScript, you will want to stay on Got v11 until TypeScript 4.6 is out. Why.
    • If you use a bundler, make sure it supports ESM and that you have correctly configured it for ESM.

    ... (truncated)

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies javascript 
    opened by dependabot[bot] 1
  • build(deps): bump time-span from 4.0.0 to 5.0.0

    build(deps): bump time-span from 4.0.0 to 5.0.0

    Bumps time-span from 4.0.0 to 5.0.0.

    Release notes

    Sourced from time-span's releases.

    v5.0.0

    Breaking

    • Require Node.js 12 00dc535
    • This package is now pure ESM. Please read this.
    • end.nanoseconds() now returns a bigint instead of a number

    https://github.com/sindresorhus/time-span/compare/v4.0.0...v5.0.0

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies javascript 
    opened by dependabot[bot] 1
  • build(deps): bump p-any from 3.0.0 to 4.0.0

    build(deps): bump p-any from 3.0.0 to 4.0.0

    Bumps p-any from 3.0.0 to 4.0.0.

    Release notes

    Sourced from p-any's releases.

    v4.0.0

    Breaking

    • Require Node.js 12.20 df9b57b
    • This package is now pure ESM. Please read this.

    https://github.com/sindresorhus/p-any/compare/v3.0.0...v4.0.0

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies javascript 
    opened by dependabot[bot] 1
Releases(v1.2.8)
Owner
Kiko Beats
Software writer.
Kiko Beats
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
AdaHandle Resolver in discord.

Handle Resolver Invite Link - requires ZERO permissions. What is Handle? Well, i suggest you to check their website. What does this bot do? You can co

AmirhN 3 Sep 10, 2022
Cloudflare DDNS (Dynamic DNS) support for UniFi OS

Cloudflare DDNS for UniFi OS A Cloudflare Worker script that exposes a UniFi-compatible DDNS API to dynamically update the IP address of a DNS A recor

William Walker 210 Jan 1, 2023
DNS-Blocklists: For a better internet - keep the internet clean!

DNS Blocklists - For a better internet! Multi - Cleans the Internet and protects your privacy! An all in one blocklist based on the OISD blocklist, ba

Gerd 280 Jan 2, 2023
Use Cloudflare Gateway DNS/VPN to block ads, malware and tracking domains - free alternative to NextDNS, Pi-hole and Adguard

Cloudflare Gateway Pi-hole Scripts (CGPS) Cloudflare Gateway allows you to create custom rules to filter HTTP, DNS, and network traffic based on your

null 70 Aug 13, 2023
The Remix version of the fakebooks app demonstrated on https://remix.run. Check out the CRA version: https://github.com/kentcdodds/fakebooks-cra

Remix Fakebooks App This is a (very) simple implementation of the fakebooks mock app demonstrated on remix.run. There is no database, but there is an

Kent C. Dodds 61 Dec 22, 2022
nest연습용 (w. https://github.com/seuiggi, https://github.com/okysky1121)

A progressive Node.js framework for building efficient and scalable server-side applications. Description Nest framework TypeScript starter repository

이름 2 Oct 5, 2022
Mirror from https://github.com/BochilGaming/games-wabot/tree/multi-device

Games-Wabot Join Group Diskusi NO BOT Deploy to Heroku Heroku Buildpack BuildPack LINK FFMPEG here IMAGEMAGICK here FOR TERMUX USER Type mentioned bel

null 48 Dec 20, 2022
A refined tool for exploring open-source projects on GitHub with a file tree, rich Markdown and image previews, multi-pane multi-tab layouts and first-class support for Ink syntax highlighting.

Ink codebase browser, "Kin" ?? The Ink codebase browser is a tool to explore open-source code on GitHub, especially my side projects written in the In

Linus Lee 20 Oct 30, 2022
proxy 🦄 yxorp is your Web Proxy as a Service (SAAS) Multi-tenant, Multi-Threaded, with Cache & Article Spinner

proxy ?? yxorp is your Web Proxy as a Service (SAAS) Multi-tenant, Multi-Threaded, with Cache & Article Spinner. Batteries are included, Content Spinning and Caching Engine, all housed within a stunning web GUI. A unique high-performance, plug-and-play, multi-threaded website mirror and article spinner

4D/ҵ.com Dashboards 13 Dec 30, 2022
A Node.js client & server implementation of the WAMP-like RPC-over-websocket system defined in the OCPP-J protcols.

OCPP-RPC A client & server implementation of the WAMP-like RPC-over-websocket system defined in the OCPP-J protcols (e.g. OCPP1.6J and OCPP2.0.1J). Re

Mikuso 14 Dec 30, 2022
node.js script to scrape all top meme templates from https://imgflip.com/memetemplates

imgflip-scraper node.js script to scrape all top meme templates from https://imgflip.com/memetemplates Acknowledgements imgflip Run Locally Clone the

Abhishek Bhathela 3 Nov 12, 2022
https://www.captchaai.io/ - simple captchaai API (next 2captcha) tasks handler for node

captchaai.io api ?? task handler Want you to get captcha verified tokens with a simple function call in you node application? Just install axios and r

qwertyy 5 Dec 9, 2022
Automating Beef to use over wan without configuring your router

BeefAuto Follow on Social Media Platforms python script Automate Beef And Configure it to use overwan by using ngrok to open ports ScreenShots INSTALL

youhacker55 50 Dec 6, 2022
Make the content slide prettily across the screen with variable sizes of scrolling items, in any of four directions, pausing while the mouse is over the marquee, and all with vanilla JavaScript.

TEG Marquee Make the content slide prettily across the screen with variable sizes of scrolling items, in any of four directions, pausing while the mou

Paul B. Joiner 0 Dec 30, 2021
Chrome extension for granular visual control over Notion.so

Notion Style Tweaks (Beta) A Chrome extension aiming to give granular control over the visual experience of Notion. Written in Svelte. Installation Ch

Eli 47 Dec 25, 2022
A port of bitcoin-core that will (over time) become TS friendly.

bitcoin-core A modern Bitcoin Core REST and RPC client to execute administrative tasks, multiwallet operations and queries about network and the block

null 6 Nov 22, 2022