* Add maxErrorsPerFile blocking configuration
The default max errors per file of 5 is too small IMHO.
This commit makes this number user-configurable.
* squash: fix lint
* squash: docs
* squash: change type to int to allow -1
* squash: test that the `maxErrorsPerFile` is actually used
---------
Co-authored-by: ThinkChaos <ThinkChaos@users.noreply.github.com>
* Added fork sync workflow(syncs the main branch with upstream every 30 minutes)
* Added monthly workflow run deletion(all skipped or canceld and runs older than 30days will be deleted)
* Removed Docker image build for main branch on forks
* Added documentation how to enable sync and docker build workflows
* 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`
Otherwise, a request to blocky could end up waiting for 2 DNS requests:
1. lookup the DNS server IP
2. forward the user request to the server looked-up in 1
To declutter the global top level config options i propose the grouping of ports and logging options as child options of top level options.
New structure:
ports:
dns: 43
http: 4000
https: 4443
tls: 853
log:
level: warn
format: json
privacy: true
timestamp: false
* Enable start if one upstream resolver fails
* Will now check if upstream actually works
* Fixed default upstream in some tests
* Increase timeouts in some tests
* change default value of "StartVerifyUpstream" to false
Co-authored-by: Dimitri Herzog <dimitri.herzog@gmail.com>
* 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>
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.
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
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.