use maxDialCacheSize constant
This commit is contained in:
parent
b3461d37ca
commit
d918e5b418
|
@ -33,6 +33,7 @@ const defaultSafebrowsingServer = "sb.adtidy.org"
|
||||||
const defaultSafebrowsingURL = "http://%s/safebrowsing-lookup-hash.html?prefixes=%s"
|
const defaultSafebrowsingURL = "http://%s/safebrowsing-lookup-hash.html?prefixes=%s"
|
||||||
const defaultParentalServer = "pctrl.adguard.com"
|
const defaultParentalServer = "pctrl.adguard.com"
|
||||||
const defaultParentalURL = "http://%s/check-parental-control-hash?prefixes=%s&sensitivity=%d"
|
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
|
// ErrInvalidSyntax is returned by AddRule when the rule is invalid
|
||||||
var ErrInvalidSyntax = errors.New("dnsfilter: invalid rule syntax")
|
var ErrInvalidSyntax = errors.New("dnsfilter: invalid rule syntax")
|
||||||
|
@ -1076,7 +1077,7 @@ func New(c *Config) *Dnsfilter {
|
||||||
ExpectContinueTimeout: 1 * time.Second,
|
ExpectContinueTimeout: 1 * time.Second,
|
||||||
}
|
}
|
||||||
if c != nil && len(c.ResolverAddress) != 0 {
|
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.transport.DialContext = d.createCustomDialContext(c.ResolverAddress)
|
||||||
}
|
}
|
||||||
d.client = http.Client{
|
d.client = http.Client{
|
||||||
|
|
Loading…
Reference in New Issue