mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-22 02:47:48 +08:00
Co-authored-by: Marcin Rataj <lidel@lidel.org> Co-authored-by: Henrique Dias <hacdias@gmail.com>
21 lines
526 B
Go
21 lines
526 B
Go
package node
|
|
|
|
import (
|
|
"math"
|
|
"time"
|
|
|
|
"github.com/ipfs/boxo/gateway"
|
|
config "github.com/ipfs/kubo/config"
|
|
doh "github.com/libp2p/go-doh-resolver"
|
|
madns "github.com/multiformats/go-multiaddr-dns"
|
|
)
|
|
|
|
func DNSResolver(cfg *config.Config) (*madns.Resolver, error) {
|
|
var dohOpts []doh.Option
|
|
if !cfg.DNS.MaxCacheTTL.IsDefault() {
|
|
dohOpts = append(dohOpts, doh.WithMaxCacheTTL(cfg.DNS.MaxCacheTTL.WithDefault(time.Duration(math.MaxUint32)*time.Second)))
|
|
}
|
|
|
|
return gateway.NewDNSResolver(cfg.DNS.Resolvers, dohOpts...)
|
|
}
|