Skip to content

Commit

Permalink
Fix #12.
Browse files Browse the repository at this point in the history
  • Loading branch information
ncruces committed Nov 14, 2023
1 parent 5cd5dad commit 353340b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 12 deletions.
4 changes: 2 additions & 2 deletions cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"time"
)

// NewCachingResolver creates a caching net.Resolver that uses parent to resolve names.
// NewCachingResolver creates a caching [net.Resolver] that uses parent to resolve names.
func NewCachingResolver(parent *net.Resolver, options ...CacheOption) *net.Resolver {
if parent == nil {
parent = &net.Resolver{}
Expand Down Expand Up @@ -55,7 +55,7 @@ func (o minTTLOption) apply(c *cache) { c.minTTL = time.Duration(o) }
func (o negativeCacheOption) apply(c *cache) { c.negative = bool(o) }

// MaxCacheEntries sets the maximum number of entries to cache.
// If zero, DefaultMaxCacheEntries is used; negative means no limit.
// If zero, [DefaultMaxCacheEntries] is used; negative means no limit.
func MaxCacheEntries(n int) CacheOption { return maxEntriesOption(n) }

// MaxCacheTTL sets the maximum time-to-live for entries in the cache.
Expand Down
4 changes: 2 additions & 2 deletions dns.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Package dns provides net.Resolver instances implementing caching,
// Package dns provides [net.Resolver] instances implementing caching,
// opportunistic encryption, and DNS over TLS/HTTPS.
//
// To replace the net.DefaultResolver with a caching DNS over HTTPS instance
// To replace the [net.DefaultResolver] with a caching DNS over HTTPS instance
// using the Google Public DNS resolver:
//
// net.DefaultResolver = dns.NewDoHResolver(
Expand Down
6 changes: 2 additions & 4 deletions doh.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ func NewDoHResolver(uri string, options ...DoHOption) (*net.Resolver, error) {

// create the resolver
var resolver = net.Resolver{
PreferGo: true,
StrictErrors: true,
PreferGo: true,
Dial: func(ctx context.Context, network, address string) (net.Conn, error) {
conn := &dnsConn{}
conn.roundTrip = dohRoundTrip(uri, &client)
Expand All @@ -89,7 +88,6 @@ func NewDoHResolver(uri string, options ...DoHOption) (*net.Resolver, error) {
conn, err := d.DialContext(ctx, network, opts.addrs[i])
if err != nil {
index.CompareAndSwap(i, (i+1)%uint32(len(opts.addrs)))
return nil, err
}
return conn, err
}
Expand All @@ -102,7 +100,7 @@ func NewDoHResolver(uri string, options ...DoHOption) (*net.Resolver, error) {
return &resolver, nil
}

// An DoHOption customizes the DNS over HTTPS resolver.
// A DoHOption customizes the DNS over HTTPS resolver.
type DoHOption interface {
apply(*dohOpts)
}
Expand Down
5 changes: 1 addition & 4 deletions dot.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,7 @@ func NewDoTResolver(server string, options ...DoTOption) (*net.Resolver, error)
}

// create the resolver
var resolver = net.Resolver{
PreferGo: true,
StrictErrors: true,
}
var resolver = net.Resolver{PreferGo: true}

// setup dialer
var index atomic.Uint32
Expand Down

0 comments on commit 353340b

Please sign in to comment.