diff --git a/internal/cmd/cache.go b/internal/cmd/cache.go index 9ec8387..067387d 100644 --- a/internal/cmd/cache.go +++ b/internal/cmd/cache.go @@ -25,9 +25,11 @@ type cacheConfig struct { // c must be valid. func (c *cacheConfig) toInternal() (conf *dnssvc.CacheConfig) { return &dnssvc.CacheConfig{ - Enabled: c.Enabled, - Size: c.Size, - ClientSize: c.ClientSize, + Enabled: c.Enabled, + // #nosec G115 -- The value is validated to not exceed [math.MaxInt]. + Size: int(c.Size), + // #nosec G115 -- The value is validated to not exceed [math.MaxInt]. + ClientSize: int(c.ClientSize), } } diff --git a/internal/dnssvc/cache.go b/internal/dnssvc/cache.go index 003f057..bd20d3e 100644 --- a/internal/dnssvc/cache.go +++ b/internal/dnssvc/cache.go @@ -1,17 +1,19 @@ package dnssvc -import "github.com/c2h5oh/datasize" - // CacheConfig is the configuration for the DNS results cache. type CacheConfig struct { // Enabled specifies if the cache should be used. Enabled bool // Size is the maximum size of the common cache. - Size datasize.ByteSize + // + // TODO(e.burkov): Make it a [datasize.ByteSize] when dnsproxy uses it. + Size int // ClientSize is the maximum size of each per-client cache. - ClientSize datasize.ByteSize + // + // TODO(e.burkov): Make it a [datasize.ByteSize] when dnsproxy uses it. + ClientSize int } // TODO(e.burkov): Add tests. diff --git a/internal/dnssvc/clientstorage.go b/internal/dnssvc/clientstorage.go index 782f251..4be964a 100644 --- a/internal/dnssvc/clientstorage.go +++ b/internal/dnssvc/clientstorage.go @@ -17,9 +17,7 @@ func (confs upstreamConfigs) clients(cacheConf *CacheConfig) (clients []*client) conf: proxy.NewCustomUpstreamConfig( conf, cacheConf.Enabled, - // #nosec G115 -- The value is validated to be less or equal to - // [math.MaxInt]. - int(cacheConf.ClientSize), + cacheConf.ClientSize, false, ), prefix: cli, diff --git a/internal/dnssvc/dnssvc.go b/internal/dnssvc/dnssvc.go index 1a4456b..6920fca 100644 --- a/internal/dnssvc/dnssvc.go +++ b/internal/dnssvc/dnssvc.go @@ -117,10 +117,8 @@ func newProxyConfig( UsePrivateRDNS: private != nil, Fallbacks: falls, TrustedProxies: trusted, - // #nosec G115 -- The value is validated to be less or equal to - // [math.MaxInt]. - CacheSizeBytes: int(conf.Cache.Size), - CacheEnabled: conf.Cache.Enabled, + CacheSizeBytes: conf.Cache.Size, + CacheEnabled: conf.Cache.Enabled, }, ups.clients(conf.Cache), nil }