dns-over-http
HTTP(s) middleware and client for DNS over HTTPS (DoH)
Abstract
DNS over HTTPS (DoH) is protocol designed for performing remote Domain Name System resolution over HTTPS. Requests are made of HTTP to increase user security and privacy. See DNS over HTTPS for more information.
This module provides a middleware function that can be directly passed
to the http.createServer()
and https.createServer()
functions for
handling DNS resolution. This module will use centralized DNS servers
for DNS queries and will cache answers from them for subsequent
requests. This module is a work-in-progres.
Installation
$ npm install dns-over-http
Usage
Creating a server
const https = const doh = const serverOptions = // with cert and keyconst server = https server
You can also use the http
module and position it behind a load
balancer or nginx instance configured SSL certificates.
*Querying for DNS resolution
const doh = const url = 'https://dns.google.com:443/experimental' const results = const lookups = type: 'A' name: 'google.com' type: 'A' name: 'littlstar.com' type: 'A' name: 'twitter.com' for const lookup of lookups doh
API
doh(opts)
Returns a function handle suitable for a http server request callback
where opts
can be:
servers: 'dns.example.com' // centralized DNS servers store: null // an optional storage interface
doh.query(opts, questions, cb)
Make a DNS resolution query request. Options are passed directly to the
http.request
function. questions
are given to a
dns-packet encoding and sent
as a POST
request with a 'application/dns-udpwireformat'
content
type.
See Also
License
MIT