kubo/core/node/dns.go
Adin Schmahmann 353dd49be2
refactor: switch gateway code to new API from go-libipfs (#9681)
Co-authored-by: Marcin Rataj <lidel@lidel.org>
Co-authored-by: Henrique Dias <hacdias@gmail.com>
2023-03-30 13:20:37 +00:00

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...)
}