Comments (16)
One question, would we be using cloudflare or google DoH APIs for this (Ex.: https://cloudflare-dns.com/dns-query). Interested to contribute here
from cacheable-lookup.
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 https://
). We can detect cacheable.servers
changes in
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 dns.Resolver
doesn't accept DoH servers so we need to filter the list before calling resolver.setServers
.
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.
from cacheable-lookup.
Thanks, would go through the specification once, DoH queries should be round robin if multiple DoH servers are given right?
from cacheable-lookup.
No, those should be fallback servers. As per Node.js docs:
Fallback DNS servers will only be used if the earlier ones time out or result in some other error.
from cacheable-lookup.
Got it, thanks
from cacheable-lookup.
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
})
from cacheable-lookup.
Awesome! It's quite heavy though, can you reduce the size?
from cacheable-lookup.
yea, I'm working on it; the main dependency is dns2 that is exporting a lot of things I really don't need
from cacheable-lookup.
Are you sure?
from cacheable-lookup.
gotcha; shipped [email protected]
that removes the logger dependency
from cacheable-lookup.
Awesome! Would you be up to sending a PR mentioning this in the docs?
from cacheable-lookup.
PR #77 fixes this! 🎉
See 🍊 Tangerine and forwardemail/nodejs-dns-over-https-tangerine#1.
from cacheable-lookup.
Reported as spam to GitHub
from cacheable-lookup.
Reported for spam
from cacheable-lookup.
BTW this is how I use cacheable-lookup
with tangerine
for getting DNS-over-HTTPs:
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 🙂
from cacheable-lookup.
You're welcome to add whatever you like! This nicely shows how it supports things other than undici
.
from cacheable-lookup.
Related Issues (20)
- Fallback fails when one family returns ENOENT HOT 1
- TS error when using QuickLRU from readme example HOT 5
- Querying for family=6 when family=4 is explicitly requested? HOT 3
- Question: How is DNS resolved? HOT 2
- DNS lookup are not cached HOT 3
- TS incompatibility between CacheableLookup.lookup and @types/node LookupFunction HOT 2
- round-robin dns support HOT 2
- Jest reporting CachableLookup is preventing shutdown HOT 3
- Ability to set minTtl? HOT 1
- Add stats to see how many calls were cached HOT 1
- Can you obtain the local hosts first and then use resolve4 or resolve6 HOT 5
- dns lookup is not cached the way I understand HOT 1
- Cacheable lookup responds with ESERVFAIL while native dns.resolve works HOT 10
- Enable tests again
- http2 & cacheable-lookup HOT 1
- Source isn't returned in Entry object HOT 1
- No way to dispose and timeout problems HOT 1
- Prefetch before expiration
- dnsCache.lookup types might be wrong? HOT 1
- Is there a version which supports CJS ? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cacheable-lookup.