Documentation
¶
Overview ¶
Package dns provides DNS-over-HTTPS resolution with caching support for the httpc library.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DoHResolver ¶
type DoHResolver struct {
// contains filtered or unexported fields
}
DoHResolver provides DNS-over-HTTPS resolution
func NewDoHResolver ¶
func NewDoHResolver(providers []*dohProvider, cacheTTL time.Duration) *DoHResolver
NewDoHResolver creates a new DoH resolver. Passing nil or an empty providers slice selects defaultDoHProviders(); custom providers can only be supplied within this package (the dohProvider type is unexported).
func (*DoHResolver) ClearCache ¶
func (r *DoHResolver) ClearCache()
ClearCache clears the DNS cache. Deletes all entries and decrements the size counter once per removed entry.
No recount/reconcile pass runs afterwards, deliberately: every counter mutation in this file is PAIRED with exactly one successful map mutation (admission: CAS+1 with a winning LoadOrStore, reverted on exists; every deletion path: -1 only when its LoadAndDelete/CompareAndDelete won the key), so the counter is accurate by construction at all times. A final "recount" Store previously overwrote the accurate value with a count taken while concurrent evictions were still decrementing — resurrecting already-consumed decrements and permanently over-counting the cache (at maxDoHCacheSize every admission then took the evict path, churning fresh entries). Two deleters can never double-decrement: LoadAndDelete and CompareAndDelete are mutually exclusive per key.
func (*DoHResolver) Close ¶ added in v1.3.8
func (r *DoHResolver) Close() error
Close releases resources held by the DoHResolver. It closes idle connections in the internal HTTP client's transport. Safe to call multiple times - subsequent calls are no-ops. Implements io.Closer for consistent resource management.
func (*DoHResolver) LookupIPAddr ¶
LookupIPAddr resolves a host name to IP addresses using DoH