* dns: disable cache with "cache_size: 0" setting

Close #1591

Squashed commit of the following:

commit 547a971f5c4f11c519dfabd52d42fa626abf931a
Author: Simon Zolin <s.zolin@adguard.com>
Date:   Tue Jun 16 14:46:06 2020 +0300

    * dns: disable cache with "cache_size: 0" setting
This commit is contained in:
Simon Zolin 2020-06-16 15:13:38 +03:00
parent 5a93c1fb59
commit ec6ca93acd
1 changed files with 5 additions and 2 deletions

View File

@ -138,8 +138,6 @@ func (s *Server) createProxyConfig() (proxy.Config, error) {
Ratelimit: int(s.conf.Ratelimit),
RatelimitWhitelist: s.conf.RatelimitWhitelist,
RefuseAny: s.conf.RefuseAny,
CacheEnabled: true,
CacheSizeBytes: int(s.conf.CacheSize),
CacheMinTTL: s.conf.CacheMinTTL,
CacheMaxTTL: s.conf.CacheMaxTTL,
UpstreamConfig: s.conf.UpstreamConfig,
@ -148,6 +146,11 @@ func (s *Server) createProxyConfig() (proxy.Config, error) {
EnableEDNSClientSubnet: s.conf.EnableEDNSClientSubnet,
}
if s.conf.CacheSize != 0 {
proxyConfig.CacheEnabled = true
proxyConfig.CacheSizeBytes = int(s.conf.CacheSize)
}
proxyConfig.UpstreamMode = proxy.UModeLoadBalance
if s.conf.AllServers {
proxyConfig.UpstreamMode = proxy.UModeParallel