Skip to content

Commit

Permalink
create custom resolvers from config
Browse files Browse the repository at this point in the history
  • Loading branch information
vyzo committed Apr 12, 2021
1 parent 957809a commit 45b9be5
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions core/node/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,17 @@ package node

import (
config "github.com/ipfs/go-ipfs-config"
doh "github.com/libp2p/go-doh-resolver"
madns "github.com/multiformats/go-multiaddr-dns"
)

func DNSResolver(cfg *config.Config) (*madns.Resolver, error) {
// TODO custom resolvers from config
return madns.DefaultResolver, nil
var opts []madns.Option
if cfg.DNS.DefaultResolver != "" {
opts = append(opts, madns.WithDefaultResolver(doh.NewResolver(cfg.DNS.DefaultResolver)))
}
for domain, url := range cfg.DNS.CustomResolvers {
opts = append(opts, madns.WithDomainResolver(domain, doh.NewResolver(url)))
}
return madns.NewResolver(opts...)
}

0 comments on commit 45b9be5

Please sign in to comment.