Commit Graph

45 Commits

Author SHA1 Message Date
Kwitsch 03131c443c
Refactoring/config struct names (#1315)
* vscode config changed in new version

* FilteringConfig -> Filtering

* CachingConfig -> Caching

* QueryLogConfig -> QueryLog

* MetricsConfig -> Metrics

* HostsFileConfig -> HostsFile

* PortsConfig -> Ports

* BootstrapDNSConfig -> BootstrapDNS

* BootstrappedUpstreamConfig -> BootstrappedUpstream

* bootstrapDNSConfig -> bootstrapDNS

* bootstrappedUpstreamConfig -> bootstrappedUpstream

* SourceLoadingConfig -> SourceLoading

* DownloaderConfig -> Downloader
2023-12-20 15:38:33 -05:00
Kwitsch fda2dbe9df
Refactoring Redis (#1271)
* RedisConfig -> Redis

* moved redis config to seperate file

* bugfix in config test during parallel processing

* implement config.Configurable in Redis config

* use Context in GetRedisCache

* use Context in New

* caching resolver test fix

* use Context in PublishEnabled

* use Context in getResponse

* remove ctx field

* bugfix in api interface test

* propperly close channels

* set ruler for go files from 80 to 111

* line break because function length is to long

* only execute redis.New if it is enabled in config

* stabilized flaky tests

* Update config/redis.go

Co-authored-by: ThinkChaos <ThinkChaos@users.noreply.github.com>

* Update config/redis_test.go

Co-authored-by: ThinkChaos <ThinkChaos@users.noreply.github.com>

* Update config/redis_test.go

Co-authored-by: ThinkChaos <ThinkChaos@users.noreply.github.com>

* Update config/redis_test.go

Co-authored-by: ThinkChaos <ThinkChaos@users.noreply.github.com>

* Update config/redis.go

Co-authored-by: ThinkChaos <ThinkChaos@users.noreply.github.com>

* Update config/redis_test.go

Co-authored-by: ThinkChaos <ThinkChaos@users.noreply.github.com>

* fix ruler

* redis test refactoring

* vscode setting cleanup

* removed else if chain

* Update redis_test.go

* context race fix

* test fail on missing seintinel servers

* cleanup context usage

* cleanup2

* context fixes

* added context util

* disabled nil context rule for tests

* copy paste error ctxSend -> CtxSend

* use util.CtxSend

* fixed comment

* fixed flaky test

* failsafe and tests

---------

Co-authored-by: ThinkChaos <ThinkChaos@users.noreply.github.com>
2023-11-27 12:08:31 -05:00
ThinkChaos eae99ec550 refactor: make use of contexts in more places
- `CacheControl.FlushCaches`
- `Querier.Query`
- `Resolver.Resolve`

Besides all the API churn, this leads to `ParallelBestResolver`,
`StrictResolver` and `UpstreamResolver` simplification: timeouts only
need to be setup in one place, `UpstreamResolver`.

We also benefit from using HTTP request contexts, so if the client
closes the connection we stop processing on our side.
2023-11-21 12:21:35 -05:00
Kwitsch d37d18348f
EDNS: Client Subnet (#1007)
* added util for handling EDNS0 options

* disable caching if the request contains a netmask size greater than 1

* added config section for ECS handling and validation for it

*added ecs_resolver for enhancing and cleaning subnet and client IP information
2023-11-20 16:56:56 +01:00
Dimitri Herzog 33ea933015
refactor: pass context for goroutine shutdown (#1187) 2023-10-07 16:21:40 -04:00
Dimitri Herzog 497bd0d0fd
chore(refactor): refactor cache implementation (#1174)
* chore(refactor): refactor cache implementation

* chore: use atomic.Uint32 as prefetch names query count

Co-authored-by: ThinkChaos <ThinkChaos@users.noreply.github.com>

---------

Co-authored-by: ThinkChaos <ThinkChaos@users.noreply.github.com>
2023-09-30 17:14:59 +02:00
Dimitri Herzog f98859325e fix: use different TTL of multiple records in answer 2023-09-25 22:12:25 +02:00
Dimitri Herzog 431b9be3e5 fix: don't cache DNS responses with CD flag 2023-09-20 23:16:49 +02:00
Dimitri Herzog 9f15228c09
fix: don't cache EDNS pseudo records (#1150)
Co-authored-by: ThinkChaos <ThinkChaos@users.noreply.github.com>
2023-09-18 09:04:08 +02:00
Dimitri Herzog d5be5884d9
fix: truncated responses should not be cached (#1149) 2023-09-17 09:43:29 +02:00
Dimitri Herzog 0157f4ce56
refactor: add generics to ExpiringCache (#933) 2023-03-15 20:32:35 +01:00
ThinkChaos 5088c75a78
refactor: configuration rework (usage and printing) (#920)
* refactor: make `config.Duration` a struct with `time.Duration` embed

Allows directly calling `time.Duration` methods.

* refactor(HostsFileResolver): don't copy individual config items

The idea is to make adding configuration options easier, and searching
for references straight forward.

* refactor: move config printing to struct and use a logger

Using a logger allows using multiple levels so the whole configuration
can be printed in trace/verbose mode, but only important parts are
shown by default.

* squash: rename `Cast` to `ToDuration`

* squash: revert `Duration` to a simple wrapper ("new type" pattern)

* squash: `Duration.IsZero` tests

* squash: refactor resolvers to rely on their config directly if possible

* squash: implement `IsEnabled` and `LogValues` for all resolvers

* refactor: use go-enum `--values` to simplify getting all log fields

* refactor: simplify `QType` unmarshaling

* squash: rename `ValueLogger` to `Configurable`

* squash: rename `UpstreamConfig` to `ParallelBestConfig`

* squash: rename `RewriteConfig` to `RewriterConfig`

* squash: config tests

* squash: resolver tests

* squash: add `ForEach` test and improve `Chain` ones

* squash: simplify implementing `config.Configurable`

* squash: minor changes for better coverage

* squash: more `UnmarshalYAML` -> `UnmarshalText`

* refactor: move `config.Upstream` into own file

* refactor: add `Resolver.Type` method

* squash: add `log` method to `typed` to use `Resolover.Type` as prefix

* squash: tweak startup config logging

* squash: add `LogResolverConfig` tests

* squash: make sure all options of type `Duration` use `%s`
2023-03-12 22:14:10 +01:00
Dimitri Herzog 53a7d4fccc
Test refactoring (#798)
* test: refactor tests

* chore: fix possible race condition in cache
2022-12-29 14:58:25 +01:00
Kwitsch 9abeaeddea
Added gofumpt (#805)
* fix linter errors

* added gofumpt

* Makefile cleanup

* gofumpt run

* Update Makefile

Co-authored-by: ThinkChaos <ThinkChaos@users.noreply.github.com>

* go mod tidy

* fmt + lint

* go mod tidy

Co-authored-by: ThinkChaos <ThinkChaos@users.noreply.github.com>
2022-12-26 22:11:45 +01:00
ThinkChaos d501d867df style(resolver): standardize configuration disabled impls and tests 2022-12-04 20:59:12 -05:00
ThinkChaos 7fa7e2ec79 refactor(resolver): only build mocks during tests
This makes iterating with breaking refactors easier as you can also
break the mocks without breaking normal compilation.

Also unexport code only used in the resolver package.
Only `MockUDPUpstreamServer` is kept as non test and exported as it is
used by the server package.
2022-12-04 20:58:59 -05:00
Dimitri Herzog 3e95b12eed feat: caching for empty DNS responses (#700) 2022-11-08 21:45:28 +01:00
Dimitri Herzog a4b89537db
update golangci-lint (#510)
* update golangci-lint

* enable gomnd linter

* enable asciicheck linter

* enable bidichk linter

* enable durationcheck linter

* enable errchkjson linter

* enable errorlint linter

* enable exhaustive linter

* enable gomoddirectives linter

* enable gomodguard guard

* enable grouper linter

* enable grouper and ifshort linters

* enable importas linter

* enable makezero linter

* enable nestif linter

* enable nilerr linter

* enable nilnil linter

* enable nlreturn linter

* enable nolintlint linter

* enable predeclared linter

* enable sqlclosecheck linter

* enable tenv linter

* enable wastedassign linter
2022-05-10 09:09:50 +02:00
Dimitri Herzog 41febafd41
chore: test cleanup and refactoring (#509)
test: added additional assertions, introduced channels for bus event tests, refactoring, eliminating race conditions in tests, enable race check in tests
2022-05-06 22:34:08 +02:00
Dimitri Herzog 0a7e46a0d4
test: added additional assertions, introduced channels for bus event tests, refactoring (#501) 2022-04-26 10:43:23 +02:00
ThinkChaos 62c7816ab3
Support of DoH/DoT as bootstrap DNS (#485) 2022-04-22 22:12:35 +02:00
Dimitri Herzog 81b896a01d chore: increased test timeout 2022-03-31 22:27:45 +02:00
ThinkChaos f8b6e59ef4
Add rewrite support to custom DNS (#449)
This commit extracts rewriting logic from `ConditionalUpstreamResolver`
into the new `RewriterResolver`, and uses that to enable rewriting for
the `CustomDNSResolver`.
`RewriterResolver` wraps a resolver and applies the rewrite to the
request that is forwarded to the inner resolver.

It also introduces a new optional interface: `NamedResolver`.
This allows a `Resolver` to choose what its user friendly name is,
instead of always being its type name.
2022-03-17 22:30:21 +01:00
ThinkChaos 27c8cbf2b7
Update to gingko v2 (#447) 2022-03-03 11:27:27 +01:00
Dimitri Herzog 759f55d89c
Rewrite DNS response cache (#378) (#413) 2022-01-20 16:45:29 +01:00
Kwitsch ee451f8b36
Sync blocking enable/disable over redis (#377) (#403)
Co-authored-by: Dimitri Herzog <dimitri.herzog@gmail.com>
2022-01-19 22:03:41 +01:00
Dimitri Herzog d7bf373b52 Replace all sleeps in tests with "eventually" from gomega (#379) 2021-12-22 22:21:04 +01:00
Kwitsch d3611fb444
FR: DNS cache sync between multiple blocky instances (#344) (#365) 2021-12-21 17:06:16 +01:00
Kwitsch 3adad4a9f9
Configurable caching for negative results (NXDOMAIN) (#287) (#330)
Changes:
- added cache.cacheTimeNegative (time.Duration)
- if not configured the default cache time stays at 30 min
- if set to a value below zero caching of negative responses is disabled
2021-11-06 22:14:02 +01:00
Dimitri Herzog c2fb389cf7 Improve caching of prefetched domains (#290) 2021-09-27 22:52:37 +02:00
Dimitri Herzog 91b975b0dc Change configuration format for duration (#263) 2021-09-12 21:29:03 +02:00
Dimitri Herzog ee8f041938 refactoring: generate enums 2021-09-11 21:31:03 +02:00
Dimitri Herzog 63735546bb moving model types to the separate package 2021-09-08 21:38:34 +02:00
Dimitri Herzog 919512959b use full-qualified name as module 2021-08-27 13:41:36 +02:00
Dimitri Herzog 30ce749698
Make the number of cached domains configurable (#211)
* #200: Make the number of cached domains configurable
2021-05-17 21:56:39 +02:00
moyo 3770dd97cf
Make prefetch fully configurable (#198)
* make prefetch fully configurable

* add configuration output test
2021-05-03 22:29:26 +02:00
moyo 9ea8419175
Add prefetch hit metrics (#190)
* add prefetch hit metrics

* add tests for prefetch hit
2021-04-24 21:48:08 +02:00
moyo 33eb062338
Make cache for all query types (#186)
* make cache for all query types

* remove query class in cacheKey
2021-04-19 08:16:27 +02:00
Dimitri Herzog 0fd25207d1 introducing event bus, refactorings 2021-01-23 22:29:43 +01:00
Dimitri Herzog 0ec6c8af9c Test rewrite (Ginkgo), Refactorings 2020-05-04 22:20:13 +02:00
Dimitri Herzog 0061cf0c10 Provide additional configuration for caching, fixes #2 2020-02-10 21:44:51 +01:00
Dimitri Herzog 5b2a78b9ec Added statistics collection and aggregation 2020-02-07 22:13:00 +01:00
Dimitri Herzog 74c3c065c2 improved negative cache handling 2020-01-27 21:16:05 +01:00
Dimitri Herzog 84e47d2cad small refactorings, additional tests 2020-01-15 22:11:02 +01:00
Dimitri Herzog 01a8a402dc initial commit 2020-01-12 18:23:35 +01:00