Skip to content

Commit

Permalink
group further into upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
cottand committed Nov 14, 2023
1 parent b7abcd2 commit a3d8a60
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 37 deletions.
40 changes: 18 additions & 22 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ type Config struct {
Nullroutev6 string
Interval int
Timeout int
Expire uint32
Maxcount int
QuestionCacheCap int
TTL uint32
Blocklist []string
Expand All @@ -50,6 +48,8 @@ type Upstream struct {
DoH string
Nameservers []string
TimeoutS int `toml:"timeout_s"`
Expire uint32
Maxcount int
}

type Metrics struct {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
16 changes: 5 additions & 11 deletions doc/src/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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]
Expand Down
8 changes: 4 additions & 4 deletions handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit a3d8a60

Please sign in to comment.