From d918e5b418de232d95ba1e3d642dca00664f0304 Mon Sep 17 00:00:00 2001 From: Simon Zolin Date: Wed, 15 May 2019 12:03:20 +0300 Subject: [PATCH] use maxDialCacheSize constant --- dnsfilter/dnsfilter.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dnsfilter/dnsfilter.go b/dnsfilter/dnsfilter.go index d474930b..b780c9f2 100644 --- a/dnsfilter/dnsfilter.go +++ b/dnsfilter/dnsfilter.go @@ -33,6 +33,7 @@ const defaultSafebrowsingServer = "sb.adtidy.org" const defaultSafebrowsingURL = "http://%s/safebrowsing-lookup-hash.html?prefixes=%s" const defaultParentalServer = "pctrl.adguard.com" const defaultParentalURL = "http://%s/check-parental-control-hash?prefixes=%s&sensitivity=%d" +const maxDialCacheSize = 2 // the number of host names for safebrowsing and parental control // ErrInvalidSyntax is returned by AddRule when the rule is invalid var ErrInvalidSyntax = errors.New("dnsfilter: invalid rule syntax") @@ -1076,7 +1077,7 @@ func New(c *Config) *Dnsfilter { ExpectContinueTimeout: 1 * time.Second, } if c != nil && len(c.ResolverAddress) != 0 { - dialCache = gcache.New(2).LRU().Expiration(defaultCacheTime).Build() + dialCache = gcache.New(maxDialCacheSize).LRU().Expiration(defaultCacheTime).Build() d.transport.DialContext = d.createCustomDialContext(c.ResolverAddress) } d.client = http.Client{