dns

package
v3.11.18 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 15, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultMaxCacheEntries = 300

Variables

This section is empty.

Functions

func NewNetResolver

func NewNetResolver(opts ...Option) *net.Resolver

NewNetResolver creates a caching net.Resolver that uses parent to resolve names.

Types

type DialFunc

type DialFunc func(ctx context.Context, network, address string) (net.Conn, error)

DialFunc is a net.Resolver.Dial function.

func NewNetDialer

func NewNetDialer(parent DialFunc, opts ...Option) DialFunc

NewNetDialer adds caching to a net.Resolver.Dial function.

type Option

type Option func(*Options)

A Option customizes the resolver cache.

func MaxCacheEntries

func MaxCacheEntries(n int) Option

MaxCacheEntries sets the maximum number of entries to cache. If zero, DefaultMaxCacheEntries is used; negative means no limit.

func MaxCacheTTL

func MaxCacheTTL(td time.Duration) Option

MaxCacheTTL sets the maximum time-to-live for entries in the cache.

func Meter added in v3.11.13

func Meter(m meter.Meter) Option

Meter sets meter.Meter

func MinCacheTTL

func MinCacheTTL(td time.Duration) Option

MinCacheTTL sets the minimum time-to-live for entries in the cache.

func NegativeCache

func NegativeCache(b bool) Option

NegativeCache sets whether to cache negative responses.

func PreferIPV4

func PreferIPV4(b bool) Option

PreferIPV4 resolve ipv4 records.

func PreferIPV6

func PreferIPV6(b bool) Option

PreferIPV6 resolve ipv4 records.

func Resolver

func Resolver(r *net.Resolver) Option

Resolver sets upstream *net.Resolver.

func Timeout

func Timeout(td time.Duration) Option

Timeout sets upstream *net.Resolver timeout

type Options

type Options struct {
	Resolver        *net.Resolver
	MaxCacheEntries int
	MaxCacheTTL     time.Duration
	MinCacheTTL     time.Duration
	NegativeCache   bool
	PreferIPV4      bool
	PreferIPV6      bool
	Timeout         time.Duration
	Meter           meter.Meter
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL