Documentation
¶
Overview ¶
Package dnssvc provides DNS handling functionality for AdGuard DNS CLI.
Index ¶
- type BindRetryConfig
- type CacheConfig
- type ClientGetter
- type Config
- type DNSService
- func (svc *DNSService) ServeDNS(ctx context.Context, p *proxy.Proxy, dctx *proxy.DNSContext) (err error)
- func (svc *DNSService) Shutdown(ctx context.Context) (err error)
- func (svc *DNSService) Start(ctx context.Context) (err error)
- func (svc *DNSService) Wrap(h proxy.Handler) (wrapped proxy.Handler)
- type DefaultClientGetter
- type FallbackConfig
- type PendingRequestsConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BindRetryConfig ¶
type BindRetryConfig struct {
// Enabled enables retrying to bind to listen addresses.
Enabled bool
// Interval is the interval to wait between retries. It must be
// non-negative.
Interval time.Duration
// Count is the maximum number of attempts excluding the first one.
Count uint
}
BindRetryConfig configures retrying to bind to listen addresses.
type CacheConfig ¶
type CacheConfig struct {
// Enabled specifies if the cache should be used.
Enabled bool
// Size is the maximum size of the common cache.
//
// TODO(e.burkov): Make it a [datasize.ByteSize] when dnsproxy uses it.
Size int
}
CacheConfig is the configuration for the DNS results cache.
type ClientGetter ¶
type ClientGetter interface {
// Address returns the client's address.
Address(dctx *proxy.DNSContext) (addr netip.AddrPort)
}
ClientGetter retrieves the client's address from the DNS context.
type Config ¶
type Config struct {
// BaseLogger used as the base logger for the DNS subservices. It must not
// be nil.
BaseLogger *slog.Logger
// Logger is the logger for the DNS service. It must not be nil.
Logger *slog.Logger
// PrivateSubnets is the set of IP networks considered private. The PTR
// requests for ARPA domains considered private if the domain contains an IP
// from one of the networks and the request came from the client within one
// of the networks. It must not be nil.
PrivateSubnets netutil.SubnetSet
// ClientStorage stores clients according to their addresses. It must not
// be nil. Storage must not be shut down until the [DNSService.Shutdown]
// returns.
ClientStorage client.Storage
// Bootstrap is a bootstrap resolver. If it is nil, than
// [net.DefaultResolver] will be used.
Bootstrap upstream.Resolver
// GeneralUpstreams represents the general upstreams. It must be valid.
GeneralUpstreams *proxy.UpstreamConfig
// PrivateRDNSUpstreams represents the private upstreams. If it is nil, the
// usage of private RDNS will be disabled.
PrivateRDNSUpstreams *proxy.UpstreamConfig
// Cache is the configuration for the DNS results cache. It must not be
// nil.
Cache *CacheConfig
// Fallbacks describes DNS fallback upstream servers. It must not be nil.
//
// TODO(m.kazantsev): Move out of there to be able to remove the bootstraps
// as well.
Fallbacks *FallbackConfig
// ClientGetter is the function to get the client for a request. It must
// not be nil.
ClientGetter ClientGetter
// BindRetry is the configuration for retrying to bind to listen addresses.
// It must not be nil.
BindRetry *BindRetryConfig
// PendingRequests is the configuration for duplicate requests handling.
// It must not be nil.
PendingRequests *PendingRequestsConfig
// ListenAddrs is the list of served addresses. It must contain at least
// one entry. It must not be empty and must contain only valid addresses.
ListenAddrs []netip.AddrPort
}
Config is the configuration for DNSService.
type DNSService ¶
type DNSService struct {
// contains filtered or unexported fields
}
DNSService is a service that provides DNS handling functionality.
func New ¶
func New(conf *Config) (svc *DNSService, err error)
New creates a new DNSService. conf must not be nil.
func (*DNSService) ServeDNS ¶ added in v0.2.0
func (svc *DNSService) ServeDNS( ctx context.Context, p *proxy.Proxy, dctx *proxy.DNSContext, ) (err error)
ServeDNS implements the proxy.Handler interface for *DNSService.
func (*DNSService) Shutdown ¶
func (svc *DNSService) Shutdown(ctx context.Context) (err error)
Shutdown implements the service.Interface interface for *DNSService.
func (*DNSService) Start ¶
func (svc *DNSService) Start(ctx context.Context) (err error)
Start implements the service.Interface interface for *DNSService.
func (*DNSService) Wrap ¶ added in v0.2.0
func (svc *DNSService) Wrap(h proxy.Handler) (wrapped proxy.Handler)
Wrap implements the proxy.Middleware interface for *DNSService.
type DefaultClientGetter ¶
type DefaultClientGetter struct{}
DefaultClientGetter is a default implementation of ClientGetter.
func (DefaultClientGetter) Address ¶
func (DefaultClientGetter) Address(dctx *proxy.DNSContext) (addr netip.AddrPort)
Address implements the ClientGetter interface for defaultClientGetter.
type FallbackConfig ¶
type FallbackConfig struct {
// Addresses is the list of servers.
Addresses []string
// Timeout is the timeout for DNS requests. Zero value disables the
// timeout.
Timeout time.Duration
}
FallbackConfig is the configuration for DNS fallback upstream servers.
type PendingRequestsConfig ¶
type PendingRequestsConfig struct {
// Enabled determines whether duplicate simultaneous requests should be
// tracked and use the result of the first one.
Enabled bool
}
PendingRequestsConfig configures duplicate requests handling.