From ec6ca93acdcd364676e002d3db1e45b451fcb552 Mon Sep 17 00:00:00 2001 From: Simon Zolin Date: Tue, 16 Jun 2020 15:13:38 +0300 Subject: [PATCH] * dns: disable cache with "cache_size: 0" setting Close #1591 Squashed commit of the following: commit 547a971f5c4f11c519dfabd52d42fa626abf931a Author: Simon Zolin Date: Tue Jun 16 14:46:06 2020 +0300 * dns: disable cache with "cache_size: 0" setting --- dnsforward/config.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/dnsforward/config.go b/dnsforward/config.go index 51b510ff..db4a043f 100644 --- a/dnsforward/config.go +++ b/dnsforward/config.go @@ -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