Revert "+ config: add cache size settings"

This reverts commit 81303b5db7.
This commit is contained in:
Simon Zolin 2019-08-16 15:11:31 +03:00
parent 68d5d595b6
commit d46ebe1c8b
2 changed files with 4 additions and 11 deletions

View File

@ -25,6 +25,7 @@ import (
"golang.org/x/net/publicsuffix" "golang.org/x/net/publicsuffix"
) )
const defaultCacheSize = 64 * 1024 // in number of elements
const defaultCacheTime = 30 * time.Minute const defaultCacheTime = 30 * time.Minute
const defaultHTTPTimeout = 5 * time.Minute const defaultHTTPTimeout = 5 * time.Minute
@ -67,10 +68,6 @@ type Config struct {
SafeBrowsingEnabled bool `yaml:"safebrowsing_enabled"` SafeBrowsingEnabled bool `yaml:"safebrowsing_enabled"`
ResolverAddress string // DNS server address ResolverAddress string // DNS server address
SafeBrowsingCacheSize int `yaml:"safebrowsing_cache_size"`
SafeSearchCacheSize int `yaml:"safesearch_cache_size"`
ParentalCacheSize int `yaml:"parental_cache_size"`
Rewrites []RewriteEntry `yaml:"rewrites"` Rewrites []RewriteEntry `yaml:"rewrites"`
// Filtering callback function // Filtering callback function
@ -857,13 +854,13 @@ func New(c *Config, filters map[int]string) *Dnsfilter {
if c != nil { if c != nil {
// initialize objects only once // initialize objects only once
if gctx.safebrowsingCache == nil { if gctx.safebrowsingCache == nil {
gctx.safebrowsingCache = gcache.New(c.SafeBrowsingCacheSize).LRU().Expiration(defaultCacheTime).Build() gctx.safebrowsingCache = gcache.New(defaultCacheSize).LRU().Expiration(defaultCacheTime).Build()
} }
if gctx.safeSearchCache == nil { if gctx.safeSearchCache == nil {
gctx.safeSearchCache = gcache.New(c.SafeSearchCacheSize).LRU().Expiration(defaultCacheTime).Build() gctx.safeSearchCache = gcache.New(defaultCacheSize).LRU().Expiration(defaultCacheTime).Build()
} }
if gctx.parentalCache == nil { if gctx.parentalCache == nil {
gctx.parentalCache = gcache.New(c.ParentalCacheSize).LRU().Expiration(defaultCacheTime).Build() gctx.parentalCache = gcache.New(defaultCacheSize).LRU().Expiration(defaultCacheTime).Build()
} }
if len(c.ResolverAddress) != 0 && gctx.dialCache == nil { if len(c.ResolverAddress) != 0 && gctx.dialCache == nil {
gctx.dialCache = gcache.New(maxDialCacheSize).LRU().Expiration(defaultCacheTime).Build() gctx.dialCache = gcache.New(maxDialCacheSize).LRU().Expiration(defaultCacheTime).Build()

View File

@ -211,10 +211,6 @@ func initConfig() {
// also change the default config // also change the default config
config.DNS.UpstreamDNS = defaultDNS config.DNS.UpstreamDNS = defaultDNS
} }
config.DNS.SafeBrowsingCacheSize = 64 * 1024
config.DNS.SafeSearchCacheSize = 64 * 1024
config.DNS.ParentalCacheSize = 64 * 1024
} }
// getConfigFilename returns path to the current config file // getConfigFilename returns path to the current config file