mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-21 18:37:45 +08:00
Some checks failed
CodeQL / codeql (push) Has been cancelled
Docker Build / docker-build (push) Has been cancelled
Gateway Conformance / gateway-conformance (push) Has been cancelled
Gateway Conformance / gateway-conformance-libp2p-experiment (push) Has been cancelled
Go Build / go-build (push) Has been cancelled
Go Check / go-check (push) Has been cancelled
Go Lint / go-lint (push) Has been cancelled
Go Test / go-test (push) Has been cancelled
Interop / interop-prep (push) Has been cancelled
Sharness / sharness-test (push) Has been cancelled
Spell Check / spellcheck (push) Has been cancelled
Interop / helia-interop (push) Has been cancelled
Interop / ipfs-webui (push) Has been cancelled
https://github.com/ipfs/kubo/pull/10883 https://github.com/ipshipyard/config.ipfs-mainnet.org/issues/3 --------- Co-authored-by: gammazero <gammazero@users.noreply.github.com>
24 lines
630 B
Go
24 lines
630 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)))
|
|
}
|
|
|
|
// Replace "auto" DNS resolver placeholders with autoconf values
|
|
resolvers := cfg.DNSResolversWithAutoConf()
|
|
|
|
return gateway.NewDNSResolver(resolvers, dohOpts...)
|
|
}
|