resolver

package
v1.43.3 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheStats added in v1.8.7

type CacheStats struct {
	Hit  uint32 `json:"hit"`
	Miss uint32 `json:"miss"`
}

type Cacher added in v1.5.0

type Cacher interface {
	Add(key, value interface{})
	Get(key interface{}) (value interface{}, ok bool)
}

type ClientInfo

type ClientInfo struct {
	ID    string
	IP    string
	Model string
	Name  string
}

type DNS

type DNS struct {
	DOH     DOH
	DNS53   DNS53
	Manager *endpoint.Manager
	// contains filtered or unexported fields
}

func (*DNS) CacheStats added in v1.8.7

func (r *DNS) CacheStats() CacheStats

func (*DNS) Resolve

func (r *DNS) Resolve(ctx context.Context, q query.Query, buf []byte) (n int, i ResolveInfo, err error)

Resolve implements Resolver interface.

type DNS53 added in v1.2.0

type DNS53 struct {
	Dialer *net.Dialer

	// Cache defines the cache storage implementation for DNS response cache. If
	// nil, caching is disabled.
	Cache Cacher

	// CacheMaxAge defines the maximum age in second allowed for a cached entry
	// before being considered stale regardless of the records TTL.
	CacheMaxAge uint32

	// MaxTTL defines the maximum TTL value that will be handed out to clients.
	// The specified maximum TTL will be given to clients instead of the true
	// TTL value if it is lower. The true TTL value is however kept in the cache
	// to evaluate cache entries freshness.
	MaxTTL uint32
}

DNS53 is a DNS53 implementation of the Resolver interface.

type DOH

type DOH struct {
	// URL specifies the DoH upstream URL.
	URL string

	// GetProfileURL provides a DoH upstream url for q. If GetProfileURL is
	// defined, URL is ignored.
	GetProfileURL func(q query.Query) (url, profile string)

	// Cache defines the cache storage implementation for DNS response cache. If
	// nil, caching is disabled.
	Cache Cacher

	// CacheMaxAge defines the maximum age in second allowed for a cached entry
	// before being considered stale regardless of the records TTL.
	CacheMaxAge uint32

	// MaxTTL defines the maximum TTL value that will be handed out to clients.
	// The specified maximum TTL will be given to clients instead of the true
	// TTL value if it is lower. The true TTL value is however kept in the cache
	// to evaluate cache entries freshness.
	MaxTTL uint32

	// ExtraHeaders specifies headers to be added to all DoH requests.
	ExtraHeaders http.Header

	// ClientInfo is called for each query in order gather client information to
	// embed with the request.
	ClientInfo func(query.Query) ClientInfo
	// contains filtered or unexported fields
}

DOH is a DNS over HTTPS implementation of the Resolver interface.

type ResolveInfo added in v1.2.7

type ResolveInfo struct {
	Transport string
	Profile   string
	FromCache bool
}

type Resolver

type Resolver interface {
	// Resolve send q and write the response into buf. If buf too small,
	// response is truncated. It is fine to reuse the same []byte for q.Payload
	// and buf.
	//
	// When caching is enabled, a cached response is returned if a valid entry
	// is found in the cache for q. In case of err with cache enabled, an
	// expired fallback entry may be stored in buf. In such case, n is > 0.
	Resolve(ctx context.Context, q query.Query, buf []byte) (n int, i ResolveInfo, err error)
}

Resolver is an interface to a type that send q to a resolver using a specific transport.

func New

func New(servers string) (Resolver, error)

New instances a DNS53 or DoH resolver for endpoint.

Supported format for servers are:

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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