Documentation ¶
Overview ¶
Package dnssvc provides DNS handling functionality for AdGuardDNSClient.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BootstrapConfig ¶
type BootstrapConfig struct { // Addresses is the list of servers. Addresses []netip.AddrPort // Timeout is the timeout for DNS requests. Timeout time.Duration }
BootstrapConfig is the configuration for DNS bootstrap servers.
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 // ClientSize is the maximum size of each per-client cache. // // TODO(e.burkov): Make it a [datasize.ByteSize] when dnsproxy uses it. ClientSize 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. PrivateSubnets netutil.SubnetSet // Cache is the configuration for the DNS results cache. It must not be // nil. Cache *CacheConfig // Bootstrap describes bootstrapping DNS servers. It must not be nil. Bootstrap *BootstrapConfig // Upstreams describes DNS upstream servers. It must not be nil. Upstreams *UpstreamConfig // Fallbacks describes DNS fallback upstream servers. It must not be nil. Fallbacks *FallbackConfig // ClientGetter is the function to get the client for a request. It must // not be nil. ClientGetter ClientGetter // 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) HandleBefore ¶
func (svc *DNSService) HandleBefore(p *proxy.Proxy, dctx *proxy.DNSContext) (err error)
HandleBefore implements the proxy.BeforeRequestHandler 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.
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 MatchCriteria ¶
type MatchCriteria struct { // Client is the prefix to match the client address. Client netip.Prefix // QuestionDomain is the suffix to match the question domain. QuestionDomain string }
MatchCriteria is the criteria for matching the upstream group to handle DNS requests. The zero value is not valid.
type UpstreamConfig ¶
type UpstreamConfig struct { // Groups is the list of groups. It should contain at least a // [agdc.UpstreamGroupNameDefault] group. Groups []*UpstreamGroupConfig // Timeout is the timeout for DNS requests. Zero value disables the // timeout. Timeout time.Duration }
UpstreamConfig is the configuration for DNS upstream servers.
TODO(e.burkov): Put the required groups into separate fields.
type UpstreamGroupConfig ¶
type UpstreamGroupConfig struct { // Name is the name of the group. Name agdc.UpstreamGroupName // Address is the address of the server. It should not be empty. Address string // Match is the list of match criteria. Match []MatchCriteria }
UpstreamGroupConfig is the configuration for a DNS upstream group.