From a3d8a603afde5cc0f5eff4f190ed1b7c45d22e9a Mon Sep 17 00:00:00 2001 From: Cottand Date: Tue, 14 Nov 2023 15:55:31 +0000 Subject: [PATCH] group further into upstream --- config.go | 40 ++++++++++++++++++---------------------- doc/src/Configuration.md | 16 +++++----------- handler.go | 8 ++++---- 3 files changed, 27 insertions(+), 37 deletions(-) diff --git a/config.go b/config.go index 28d8c89..d5233d2 100644 --- a/config.go +++ b/config.go @@ -32,8 +32,6 @@ type Config struct { Nullroutev6 string Interval int Timeout int - Expire uint32 - Maxcount int QuestionCacheCap int TTL uint32 Blocklist []string @@ -50,6 +48,8 @@ type Upstream struct { DoH string Nameservers []string TimeoutS int `toml:"timeout_s"` + Expire uint32 + Maxcount int } type Metrics struct { @@ -92,9 +92,7 @@ sources = [ ] # list of locations to recursively read blocklists from (warning, every file found is assumed to be a hosts-file or domain list) -sourcedirs = [ - "sources" -] +sourcedirs = ["sources"] # log configuration # format: comma separated list of options, where options is one of @@ -123,20 +121,9 @@ nullroute = "0.0.0.0" # ipv6 address to forward blocked queries to nullroutev6 = "0:0:0:0:0:0:0:0" -# nameservers to forward queries to -nameservers = ["1.1.1.1:53", "1.0.0.1:53"] - -# concurrency interval for lookups in miliseconds +# concurrency interval for lookups in milliseconds interval = 200 -# query timeout for dns lookups in seconds -timeout = 5 - -# cache entry lifespan in seconds -expire = 600 - -# cache capacity, 0 for infinite -maxcount = 0 # question cache capacity, 0 for infinite but not recommended (this is used for storing logs) questioncachecap = 5000 @@ -156,19 +143,28 @@ customdnsrecords = [ # "example.other.tld IN CNAME wikipedia.org" ] -# Dns over HTTPS upstream provider to use -DoH = "https://cloudflare-dns.com/dns-query" - # How deep to follow chains of CNAME records # set to 0 to disable CNAME-following entirely # (anything more than 10 should be more than plenty) # see https://github.com/Cottand/leng/wiki/CNAME%E2%80%90following-DNS followCnameDepth = 12 +[Upstream] + # Dns over HTTPS provider to use. + DoH = "https://cloudflare-dns.com/dns-query" + # nameservers to forward queries to + nameservers = ["1.1.1.1:53", "1.0.0.1:53"] + # query timeout for dns lookups in seconds + timeout_s = 5 + # cache entry lifespan in seconds + expire = 600 + # cache capacity, 0 for infinite + maxcount = 0 + # Prometheus metrics - disabled by default [Metrics] - enabled = false - path = "/metrics" + enabled = false + path = "/metrics" [DnsOverHttpServer] enabled = false diff --git a/doc/src/Configuration.md b/doc/src/Configuration.md index 2b68067..f1e6f7b 100644 --- a/doc/src/Configuration.md +++ b/doc/src/Configuration.md @@ -48,12 +48,6 @@ nullroutev6 = "0:0:0:0:0:0:0:0" # concurrency interval for lookups in miliseconds interval = 200 -# cache entry lifespan in seconds -expire = 600 - -# cache capacity, 0 for infinite -maxcount = 0 - # question cache capacity, 0 for infinite but not recommended (this is used for storing logs) questioncachecap = 5000 @@ -74,16 +68,16 @@ customdnsrecords = [ [Upstream] - #Dns over HTTPS provider to use. + # Dns over HTTPS provider to use. DoH = "https://cloudflare-dns.com/dns-query" - # nameservers to forward queries to nameservers = ["1.1.1.1:53", "1.0.0.1:53"] - # query timeout for dns lookups in seconds timeout_s = 5 - - + # cache entry lifespan in seconds + expire = 600 + # cache capacity, 0 for infinite + maxcount = 0 # Prometheus metrics - enable [Metrics] diff --git a/handler.go b/handler.go index dc4d7f2..e5ceb95 100644 --- a/handler.go +++ b/handler.go @@ -70,12 +70,12 @@ func NewEventLoop(config *Config, blockCache *MemoryBlockCache, questionCache *M resolver = &Resolver{clientConfig} cache = &MemoryCache{ - Backend: make(map[string]*Mesg, config.Maxcount), - Maxcount: config.Maxcount, + Backend: make(map[string]*Mesg, config.Upstream.Maxcount), + Maxcount: config.Upstream.Maxcount, } negCache = &MemoryCache{ Backend: make(map[string]*Mesg), - Maxcount: config.Maxcount, + Maxcount: config.Upstream.Maxcount, } handler := &EventLoop{ @@ -240,7 +240,7 @@ func (h *EventLoop) responseFor(Net string, req *dns.Msg, _local net.Addr, _remo } //find the smallest ttl - ttl := h.config.Expire + ttl := h.config.Upstream.Expire var candidateTTL uint32 for index, answer := range mesg.Answer {