Merge: + DNS: new settings cache_ttl_min, cache_ttl_max

Close #1214

Squashed commit of the following:

commit e445125556c9f9441c3d6936cb923db0a7e58260
Merge: c88b25ca 63923fa8
Author: Simon Zolin <s.zolin@adguard.com>
Date:   Fri Mar 20 19:12:21 2020 +0300

    Merge remote-tracking branch 'origin/master' into 1214-cache-min-ttl

commit c88b25ca4b641918f32811212c2cf3b63a5bf654
Author: Simon Zolin <s.zolin@adguard.com>
Date:   Fri Mar 20 19:02:17 2020 +0300

    minor

commit ec3dc21bb211941c71adcec38796eeadb978b2b7
Author: Simon Zolin <s.zolin@adguard.com>
Date:   Thu Mar 19 12:18:08 2020 +0300

    + DNS: new settings cache_ttl_min, cache_ttl_max
This commit is contained in:
Simon Zolin 2020-03-20 19:16:55 +03:00
parent 63923fa882
commit c8285c41d7
3 changed files with 11 additions and 7 deletions

View File

@ -149,7 +149,9 @@ type FilteringConfig struct {
ParentalBlockHost string `yaml:"parental_block_host"`
SafeBrowsingBlockHost string `yaml:"safebrowsing_block_host"`
CacheSize uint `yaml:"cache_size"` // DNS cache size (in bytes)
CacheSize uint32 `yaml:"cache_size"` // DNS cache size (in bytes)
CacheMinTTL uint32 `yaml:"cache_ttl_min"` // override TTL value (minimum) received from upstream server
CacheMaxTTL uint32 `yaml:"cache_ttl_max"` // override TTL value (maximum) received from upstream server
UpstreamDNS []string `yaml:"upstream_dns"`
}
@ -294,6 +296,8 @@ func (s *Server) Prepare(config *ServerConfig) error {
RefuseAny: s.conf.RefuseAny,
CacheEnabled: true,
CacheSizeBytes: int(s.conf.CacheSize),
CacheMinTTL: s.conf.CacheMinTTL,
CacheMaxTTL: s.conf.CacheMaxTTL,
Upstreams: s.conf.Upstreams,
DomainsReservedUpstreams: s.conf.DomainsReservedUpstreams,
BeforeRequestHandler: s.beforeRequestHandler,

4
go.mod
View File

@ -3,7 +3,7 @@ module github.com/AdguardTeam/AdGuardHome
go 1.13
require (
github.com/AdguardTeam/dnsproxy v0.23.7
github.com/AdguardTeam/dnsproxy v0.24.0
github.com/AdguardTeam/golibs v0.3.0
github.com/AdguardTeam/urlfilter v0.9.1
github.com/NYTimes/gziphandler v1.1.1
@ -17,7 +17,7 @@ require (
github.com/krolaw/dhcp4 v0.0.0-20180925202202-7cead472c414
github.com/miekg/dns v1.1.26
github.com/pkg/errors v0.8.1
github.com/sparrc/go-ping v0.0.0-20181106165434-ef3ab45e41b0
github.com/sparrc/go-ping v0.0.0-20190613174326-4e5b6552494c
github.com/stretchr/testify v1.4.0
go.etcd.io/bbolt v1.3.3 // indirect
golang.org/x/crypto v0.0.0-20191227163750-53104e6ec876

8
go.sum
View File

@ -1,5 +1,5 @@
github.com/AdguardTeam/dnsproxy v0.23.7 h1:RINLso8/CH4Ugfydk+rQLuKVTy4zwZRQKVRymqGDVkQ=
github.com/AdguardTeam/dnsproxy v0.23.7/go.mod h1:2qy8rpdfBzKgMPxkHmPdaNK4XZJ322v4KtVGI8s8Bn0=
github.com/AdguardTeam/dnsproxy v0.24.0 h1:GuweAeh9CLCeaNQiXGeuRHi7vWzHXhzZzC7kxRO6YA4=
github.com/AdguardTeam/dnsproxy v0.24.0/go.mod h1:TPJqGt5Ys0mSeBnSMlD1VOdSLdjYykoawe+M2qPQc10=
github.com/AdguardTeam/golibs v0.2.4 h1:GUssokegKxKF13K67Pgl0ZGwqHjNN6X7sep5ik6ORdY=
github.com/AdguardTeam/golibs v0.2.4/go.mod h1:R3M+mAg3nWG4X4Hsag5eef/TckHFH12ZYhK7AzJc8+U=
github.com/AdguardTeam/golibs v0.3.0 h1:1zO8ulGEOdXDDM++Ap4sYfTsT/Z4tZBZtiWSA4ykcOU=
@ -123,8 +123,8 @@ github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4 h1:udFKJ0aHUL60LboW/A+D
github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4/go.mod h1:qsXQc7+bwAM3Q1u/4XEfrquwF8Lw7D7y5cD8CuHnfIc=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
github.com/sparrc/go-ping v0.0.0-20181106165434-ef3ab45e41b0 h1:mu7brOsdaH5Dqf93vdch+mr/0To8Sgc+yInt/jE/RJM=
github.com/sparrc/go-ping v0.0.0-20181106165434-ef3ab45e41b0/go.mod h1:eMyUVp6f/5jnzM+3zahzl7q6UXLbgSc3MKg/+ow9QW0=
github.com/sparrc/go-ping v0.0.0-20190613174326-4e5b6552494c h1:gqEdF4VwBu3lTKGHS9rXE9x1/pEaSwCXRLOZRF6qtlw=
github.com/sparrc/go-ping v0.0.0-20190613174326-4e5b6552494c/go.mod h1:eMyUVp6f/5jnzM+3zahzl7q6UXLbgSc3MKg/+ow9QW0=
github.com/spf13/cobra v0.0.3 h1:ZlrZ4XsMRm04Fr5pSFxBgfND2EBVa1nLpiy1stUsX/8=
github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg=