Documentation ¶
Overview ¶
Package dnssvc contains AdGuard DNS's main DNS services.
Prefer to keep all mentions of module dnsserver within this package and package agd.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // Messages is the message constructor used to create blocked and other // messages for this DNS service. Messages *dnsmsg.Constructor // Cloner is used to clone messages more efficiently by disposing of parts // of DNS responses for later reuse. Cloner *dnsmsg.Cloner // ControlConf is the configuration of socket options. ControlConf *netext.ControlConfig // ConnLimiter, if not nil, is used to limit the number of simultaneously // active stream-connections. ConnLimiter *connlimiter.Limiter // AccessManager is used to block requests. AccessManager access.Interface // SafeBrowsing is the safe browsing TXT hash matcher. SafeBrowsing filter.HashMatcher // BillStat is used to collect billing statistics. BillStat billstat.Recorder // ProfileDB is the AdGuard DNS profile database used to fetch data about // profiles, devices, and so on. ProfileDB profiledb.Interface // DNSCheck is used by clients to check if they use AdGuard DNS. DNSCheck dnscheck.Interface // NonDNS is the handler for non-DNS HTTP requests. NonDNS http.Handler // DNSDB is used to update anonymous statistics about DNS queries. DNSDB dnsdb.Interface // ErrColl is the error collector that is used to collect critical and // non-critical errors. ErrColl errcoll.Interface // FilterStorage is the storage of all filters. FilterStorage filter.Storage // GeoIP is the GeoIP database used to detect geographic data about IP // addresses in requests and responses. GeoIP geoip.Interface // QueryLog is used to write the logs into. QueryLog querylog.Interface // RuleStat is used to collect statistics about matched filtering rules and // rule lists. RuleStat rulestat.Interface // NewListener, when set, is used instead of the package-level function // NewListener when creating a DNS listener. // // TODO(a.garipov): The handler and service logic should really not be // intertwined in this way. See AGDNS-1327. NewListener NewListenerFunc // Handler is used as the main DNS handler instead of a simple forwarder. // It must not be nil. // // TODO(a.garipov): Think of a better way to make the DNS server logic more // testable. Handler dnsserver.Handler // RateLimit is used for allow or decline requests. RateLimit ratelimit.Interface // FilteringGroups are the DNS filtering groups. Each element must be // non-nil. FilteringGroups map[agd.FilteringGroupID]*agd.FilteringGroup // ServerGroups are the DNS server groups. Each element must be non-nil. ServerGroups []*agd.ServerGroup // HandleTimeout defines the timeout for the entire handling of a single // query. HandleTimeout time.Duration // CacheSize is the size of the DNS cache for domain names that don't // support ECS. // // TODO(a.garipov): Extract this and following fields to cache configuration // struct. CacheSize int // ECSCacheSize is the size of the DNS cache for domain names that support // ECS. ECSCacheSize int // CacheMinTTL is the minimum supported TTL for cache items. This setting // is used when UseCacheTTLOverride set to true. CacheMinTTL time.Duration // UseCacheTTLOverride shows if the TTL overrides logic should be used. UseCacheTTLOverride bool // UseECSCache shows if the EDNS Client Subnet (ECS) aware cache should be // used. UseECSCache bool // ProfileDBEnabled is true, if user devices and profiles recognition is // enabled. ProfileDBEnabled bool // ResearchMetrics controls whether research metrics are enabled or not. // This is a set of metrics that we may need temporary, so its collection is // controlled by a separate setting. ResearchMetrics bool // ResearchLogs controls whether logging of additional info for research // purposes is enabled. These logs may be overly verbose and are only // required temporary, that's why it's controlled by a separate setting. // This setting will only be used when ResearchMetrics is also set to true. ResearchLogs bool }
Config is the configuration of the AdGuard DNS service.
type Listener ¶
Listener is a type alias for dnsserver.Server to make internal naming more consistent.
func NewListener ¶
func NewListener( s *agd.Server, baseConf dnsserver.ConfigBase, nonDNS http.Handler, ) (l Listener, err error)
NewListener returns a new Listener. It is the default DNS listener constructor.
TODO(a.garipov): Replace this in tests with netext.ListenConfig.
type NewListenerFunc ¶
type NewListenerFunc func( s *agd.Server, baseConf dnsserver.ConfigBase, nonDNS http.Handler, ) (l Listener, err error)
NewListenerFunc is the type for DNS listener constructors.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is the main DNS service of AdGuard DNS.
func (*Service) Handle ¶
func (svc *Service) Handle( ctx context.Context, grpName agd.ServerGroupName, srvName agd.ServerName, rw dnsserver.ResponseWriter, r *dns.Msg, ) (err error)
Handle is a simple helper to test the handling of DNS requests.
TODO(a.garipov): Remove once the mainmw refactoring is complete.
func (*Service) Shutdown ¶
Shutdown implements the service.Interface interface for *Service.
Directories ¶
Path | Synopsis |
---|---|
Package internal contains common utilities for DNS middlewares.
|
Package internal contains common utilities for DNS middlewares. |
accessmw
Package accessmw contains the access middleware of the AdGuard DNS server.
|
Package accessmw contains the access middleware of the AdGuard DNS server. |
dnssvctest
Package dnssvctest contains common constants and utilities for the internal DNS-service packages.
|
Package dnssvctest contains common constants and utilities for the internal DNS-service packages. |
initial
Package initial contains the initial, outermost (except for ratelimit and access) middleware of the AdGuard DNS server.
|
Package initial contains the initial, outermost (except for ratelimit and access) middleware of the AdGuard DNS server. |
mainmw
Package mainmw contains the main middleware of AdGuard DNS.
|
Package mainmw contains the main middleware of AdGuard DNS. |
preservice
Package preservice contains the middleware that comes right before the main filtering middleware of DNS service.
|
Package preservice contains the middleware that comes right before the main filtering middleware of DNS service. |
preupstream
Package preupstream contains the middleware that prepares records for upstream handling and caches them, as well as records anonymous DNS statistics.
|
Package preupstream contains the middleware that prepares records for upstream handling and caches them, as well as records anonymous DNS statistics. |