Commit Graph

55 Commits

Author SHA1 Message Date
ThinkChaos 8c7b89cbb3 refactor(tests): remove `TmpFile.Error` to centralize error checks 2023-12-01 15:53:11 -05:00
ThinkChaos 891d0fba74 refactor(tests): move `DeferCleanup` into helper functions 2023-12-01 15:53:11 -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
Kwitsch 9a77dcdccc BlockingConfig -> Blocking 2023-11-21 21:35:41 -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
Dimitri Herzog 33ea933015
refactor: pass context for goroutine shutdown (#1187) 2023-10-07 16:21:40 -04:00
DerRockWolf c112e86740
feat: add upstream strategy `strict` (#1093) 2023-08-21 09:50:23 +02:00
ThinkChaos cfc3699ab5 feat: support multiple hosts files 2023-07-07 09:16:20 -04: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 120e32c1eb
feat: client name in clientGroupsBlock should not be case-sensitive (#894) (#913) 2023-03-07 14:23:02 +01:00
ThinkChaos 2cb826db22 fix: `connectIPVersion` not being respected for upstream connections 2023-01-23 19:30:02 -05: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
Dimitri Herzog 3c40ce5d3b
fix: no initial cache refresh with "fast" start strategy (#804) 2022-12-17 23:06:58 +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
ThinkChaos c06c017a1a fix: `startVerifyUpstream` not disabling all start checks 2022-12-02 12:56:44 -05:00
Kwitsch 3dc6cb33f9 flaky fixes 2022-09-23 23:42:18 +02:00
Kwitsch fd93f67899
feat: new parameter "StartStrategy" (#566) (#636)
Blocky should start resolving DNS traffic as soon as possible
2022-09-03 22:12:07 +02:00
Kwitsch 9c80a5f9a9
test: use dynamic unit test data (#624) 2022-08-06 22:44:26 +02:00
Kwitsch 51ef9ea77f
test: fix flaky test(537) - second hunt (#610)
* go test -> ginkgo

* removed flake-attempts as suggested

* added FlakeAttempts to flaky test definition

* as net.DNSError qualifies as net.Error check and correct the response

* fix in downloader.go resolves flaky tests

* unwrap maybe?

* excluede DownloadFile from funlen linter

* use eventually on io operations in file_writer_test

* file_writer_test flaky fixes

* fix linter errors

* Serve test reversed go routine

* matcher fix

* serve test rework 2

* DeferCleanup tmp files

* fixed some flakiness in resolver tests

* go mod tidy

* fixed linter errors

* JustAfterEach -> DeferCleanup

* changed close to defer

* moved unwrap from downloader to test

* fix linter error

* propper cleanup in "should return error"

Co-authored-by: Dimitri Herzog <dimitri.herzog@gmail.com>
2022-08-01 22:27:11 +02: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
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 f9369d8fe0 Use full qualified client name as group name (#329) 2022-02-22 10:55:26 +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 bd1886d8fa
Allow to define different client names for the same group (#251) (#337)
* comama seperated client names

(cherry picked from commit cdb009d0c8e14b2be25b6a8beb563017c603f674)

* blocking_resolver unittest

(cherry picked from commit cb059deb282bcc614939dc021041c0b35665a84e)

* linter errors reduced

* unit test for group merge
2021-11-14 21:28:52 +01:00
Dimitri Herzog f823db19c7 Refactoring default parameters in configuration 2021-11-05 23:00:54 +01:00
Dimitri Herzog 2aed746d2f introduced "failStartOnListError" parameter (#310) 2021-10-14 21:53:54 +02:00
Kwitsch e5b44f49ca
application startup should fail if initial download of a single list failed (#310) (#313)
application startup should fail if initial download of a single list failed
2021-10-13 21:30:14 +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
Gonzalo Arreche 9d33bcd3a1 Allow configuration of block time
When an address is blocked, it can be cached by the client. If we
then wish to allow that address, or just disable the blocking
feature, that client is not gonna be able to see that domain until
the previous domain expires.

The units of time for this setting is in seconds, since we might
want to set it to values around 5 or 10 seconds, depending on the
scenario. The default value for it is the value used before, so
ignoring this setting wont result on any change.
2021-09-06 21:46:35 +02:00
Dimitri Herzog 919512959b use full-qualified name as module 2021-08-27 13:41:36 +02:00
invist dd69a3e664
#202: WhitelistOnly Fix for multiple entries (#199)
* Update blocking_resolver.go

Adjusted WhitelistOnly

* added test

* fixed golint issues

Co-authored-by: Dimitri Herzog <dimitri.herzog@gmail.com>
2021-05-05 22:07:14 +02:00
Dimitri Herzog 314922a028 #111: allow the ability to enable/disable blocking by group 2021-04-28 22:38:23 +02:00
Dimitri Herzog 6f5384650e #165: Block additional DNS record types 2021-03-26 22:30:48 +01:00
Dimitri Herzog 8f23f47a6d Renamed function, replaced global variable with function call, Initialize global logger only once, minor refactorings, fixed failing tests 2021-02-25 23:36:39 +01:00
Dimitri Herzog 00fc86f91f Refactoring REST Api 2021-02-04 22:27:02 +01:00
Dimitri Herzog 0fd25207d1 introducing event bus, refactorings 2021-01-23 22:29:43 +01:00
Dimitri Herzog 89f062f605 #92: wildcard support for client names 2020-08-24 22:15:31 +02:00
Dimitri Herzog 9592cb3f4b
#90: clientGroupsBlock support CIDR (#91) 2020-08-24 21:47:28 +02:00
Dimitri Herzog 1f9549098d #50: Custom ip as destination for blockType 2020-05-16 21:47:32 +02:00
Dimitri Herzog 0ec6c8af9c Test rewrite (Ginkgo), Refactorings 2020-05-04 22:20:13 +02:00
Dimitri Herzog 0766c6480a #27: CLI tool 2020-04-08 23:03:07 +02:00