boxo icon indicating copy to clipboard operation
boxo copied to clipboard

Gateway: ensure consistent caching of DNS records

Open hsanjuan opened this issue 1 year ago • 4 comments

The gateway code uses https://github.com/multiformats/go-multiaddr-dns which by default would use net.DefaultResolver and not cache anything. It also registers two default resolvers for .eth and .crypto. In this case using DoH urls for which it uses https://github.com/libp2p/go-doh-resolver, which does include caching of results.

This means some dns results are going to be cached while others depend on what DNS resolver Go is actually using (which depends on CGO iirc). When not using CGO, Go would use its own resolver and not cache anything. When using CGO, go would use the system's resolver which may or not cache stuff depending what is on the system.

Is my understanding correct @lidel ?

Ideally we should be caching all results. This has been used before in the ecosystem: https://github.com/rs/dnscache

hsanjuan avatar Oct 06 '23 16:10 hsanjuan