-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DNS over HTTPS support #40
Comments
One question, would we be using cloudflare or google DoH APIs for this (Ex.: https://cloudflare-dns.com/dns-query). Interested to contribute here |
I think the CloudFlare one is a good start to implement, then we can do something like this: const cacheable = new CacheableLookup();
cacheable.servers = [
'8.8.8.8', // DNS over UDP/TCP
'https://1.1.1.1/dns-query', // DNS over HTTPS
]; There's a spec at https://datatracker.ietf.org/doc/html/rfc8484 I'd do this by storing HTTP/2 sessions in an object (key would be a string starting with cacheable-lookup/source/index.js Lines 134 to 138 in 45b18da
so when it's updated, we close sessions that are no longer required and open new ones if there shall be. Then when a user makes a DNS request cacheable-lookup/source/index.js Line 240 in 45b18da
we simply go through the list and send a HTTP/2 request to the DoH server and handle that. Note that It's possible that there may be multiple DoH servers. This can be quite a hassle, so no need to do this all in one PR. |
Thanks, would go through the specification once, DoH queries should be round robin if multiple DoH servers are given right? |
No, those should be fallback servers. As per Node.js docs:
|
Got it, thanks |
I created doh-resolver to use DNS-over-HTTPS as resolver with cacheable-lookup: 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'] })
const cacheable = new CacheableLookup({ resolver })
https.get('https://example.com', { lookup: cacheable.lookup }, response => {
// Handle the response here
}) |
Awesome! It's quite heavy though, can you reduce the size? |
yea, I'm working on it; the main dependency is dns2 that is exporting a lot of things I really don't need |
gotcha; shipped |
Awesome! Would you be up to sending a PR mentioning this in the docs? |
PR #77 fixes this! 🎉 See 🍊 Tangerine and forwardemail/nodejs-dns-over-https-tangerine#1. |
Reported as spam to GitHub |
Reported for spam |
BTW this is how I use new CacheableLookup({
resolver: new Tangerine(
{
cache: false,
},
require('got').extend({
responseType: 'buffer',
decompress: false,
retry: 0
})
)
}) If this looks good to @titanism I can create a PR to add it into the README 🙂 |
You're welcome to add whatever you like! This nicely shows how it supports things other than |
No description provided.
The text was updated successfully, but these errors were encountered: