Commit Graph

140 Commits

Author SHA1 Message Date
ThinkChaos 1edf8cc355 fix: obfuscate secrets using a constant length string 2024-04-02 15:03:40 -04:00
ThinkChaos d83b7432d4 refactor(log): use `logrus.Level` directly and document `trace` level 2024-03-19 19:10:07 -04:00
Ben 9f633f18d0
feat: Support defining records by dns zone format (#1360)
* feat: Support zonefile configuration for custom dns mapping

* docs: Update configuration.md

* Rename var to ok

* Linter fixes

* Remove hashes in test describe description

* Implement PR comments; zoneFileMapping -> zone, initialize with proper sizes

* Remove custom CNAME parsing

* Utilize TTL defined in zone file

* Link to wikipedia's example file

* Test to confirm that a relative zone entry without an $ORIGIN returns an error

* Write a test covering the $INCLUDE directive

* Write a test confirming that a dns zone can result in more than 1 RR

* Linting

* fix: Use proper matchers in CustomDNS Zone tests; Update configuration.md description

* Pull in config directory to support relative $INCLUDE

* Added tests to ensure the ability to use both bare filenames as well as relative filenames when using the $INCLUDE directive

* Shorten test description (Linting error)

* Move Assignment of z.RRs to the end of the UnmarshallYAML function

* Moved tests for relative $INCLUDE zones to config_test. Added test case when config param passed to blocky is a directory

* Corrected test case to _actually_ test againt bare file names
2024-02-09 17:28:58 +01:00
ThinkChaos 79fc06f6c2 test(config): make sure `docs/config.yml` doesn't use deprecated options 2024-01-12 09:35:41 -05:00
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
ThinkChaos fa2d8149ba style(config): remove unused `nolint` 2023-12-05 20:52:46 -05:00
ThinkChaos ef29cdc45e refactor(config): ensure `upstreams.timeout` is always valid 2023-12-05 20:52:46 -05:00
ThinkChaos a6654dcd57 refactor(config): rename `StartStrategyType` to `InitStrategy` 2023-12-05 20:52:46 -05:00
ThinkChaos 7a3c054b43 feat: add `upstreams.init.strategy`
Replaces `startVerifyUpstream` and behaves just like
`blocking.loading.strategy`.

We use the bootstrap resolver for any requests that arrive before the
upstreams are initialized.
2023-12-05 20:52:46 -05:00
ThinkChaos 659076dd7b refactor(resolvers): make `Bootstrap` implement `Resolver` 2023-12-05 20:52:46 -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 270dc178dc refactor(config): add `TLSVersion` type 2023-11-23 08:45:18 -05:00
ThinkChaos 7d93ffb80c refactor: remove the `config` global 2023-11-23 08:45:18 -05:00
ThinkChaos e4be0c0c86 refactor(config): remove `GetConfig` and its last uses 2023-11-23 08:45:18 -05:00
ThinkChaos 23359d1471 style(config): add `config/migration` to `dot-import` allow-list 2023-11-23 08:45:18 -05:00
ThinkChaos 02cf4903f3 refactor(util): use `LogPrivacy` global instead of `GetConfig`
A global is a global, but at least this one is more targeted.
2023-11-23 08:45:18 -05:00
ThinkChaos 9760735f3a refactor(config): move `dohUserAgent` to `upstreams.userAgent`
That way it can be accessed without using `GetConfig`
2023-11-23 08:45:18 -05:00
ThinkChaos b386e22ebe refactor: embed `Upstreams` in `UpstreamGroup` to make values accessible
Move `startVerifyUpstream` to `upstreams.startVerify` so it's accessible
via `UpstreamGroup` and we don't need to pass `startVerify` to all
resolver constructors that call `NewUpstreamResolver`.

Also has the nice benefit of greatly reducing the usage of `GetConfig`.
2023-11-23 08:45:18 -05:00
Kwitsch e30e852c86 ClientLookupConfig -> ClientLookup 2023-11-21 21:35:41 -05:00
Kwitsch 9a77dcdccc BlockingConfig -> Blocking 2023-11-21 21:35:41 -05:00
Kwitsch 00d4341271 ConditionalUpstreamConfig -> ConditionalUpstream 2023-11-21 21:35:41 -05:00
Kwitsch 26d5f6215f CustomDNSConfig -> CustomDNS 2023-11-21 21:35:41 -05:00
Kwitsch 72352a968a UpstreamsConfig -> Upstreams 2023-11-21 21:35:41 -05:00
Kwitsch 1a1891c8b6
symbol name refactoring (#1263)
* ECSConfig -> ECS

* EdeConfig -> EDE

* EdeResolver -> EDEResolver

* SUDNConfig -> SUDN

* FqdnOnlyConfig -> FQDNOnly

* FqdnOnlyResolver -> FQDNOnlyResolver
2023-11-21 06:33:38 +01: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
DerRockWolf 94663eeaeb
feat: add upstream strategy `random` (#1221)
Also simplify code by getting rid of `resolversPerClient` and all surrounding logic.
2023-11-18 15:42:14 -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 639fba5323 refactor(config): allow more configuration for `upstreams`
Rename the `upstream` option to `upstreams.groups` so we can have
more `upstreams` options.
2023-08-01 15:01:40 -04:00
ThinkChaos 56633da0a7 feat(sudn): refactor and expand supported special use domains RFCs 2023-07-14 17:38:13 -04:00
ThinkChaos f22e310501 fix: duration checks to take into account values can be negative
Replace `IsZero` with `IsAboveZero` to help us avoid this mistake again.
2023-07-07 09:16:20 -04:00
ThinkChaos cfc3699ab5 feat: support multiple hosts files 2023-07-07 09:16:20 -04:00
ThinkChaos 5e4c155793 refactor(config): add migration package to simplify deprecating settings
Deprecated settings use pointers to allow knowing if they are actually
set in the user config.
They are also nested in a struct which ensures they aren't still used
since any old code would fail to compile, and easily make them
discoverable by `migration.Migrate`.
2023-07-07 09:16:20 -04:00
ThinkChaos 795f3ddf93
fix: configuration for FQDN only resolver (#1025) 2023-05-15 10:24:07 -04:00
Dimitri Herzog d61d96399a
build(deps): update github.com/creasty/defaults (#929) 2023-03-14 17:45:42 +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
ThinkChaos 63f65002e8 feat: always prefetch upstream IPs to avoid stalling user queries
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
2023-01-18 18:57:55 +01:00
ThinkChaos a79459987b feat(bootstrap): support multiple upstreams
If more than one upstream is configured, they are raced via
a `ParallelBestResolver`.
2023-01-18 18:57:55 +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
Kwitsch b73cd3b5ba
Config restructuring (#771)
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
2022-12-02 21:55:40 +01:00
Dimitri Herzog f78a57a94d
chore(build): add additional linters (#774)
* chore(build): add nolintlint linter

* chore(build): add usestdlibvars linter
2022-11-29 21:58:26 +01:00
Dimitri Herzog 2b49c2048f
feat(querylog): define which information should be logged (#765) (#766) 2022-11-26 22:12:56 +01:00
Kwitsch c19d4bd60d
feat: Support for redis sentinel(#632)
Co-authored-by: Dimitri Herzog <dimitri.herzog@gmail.com>
2022-11-24 14:37:48 +01:00
Dimitri Herzog a5ef595f43 fix: change network names (#703) 2022-11-02 21:58:58 +01:00
Kwitsch 6b260159bb
Merge branch 'development' into feat/config-ignore-non-yaml 2022-09-23 22:32:57 +02:00
ThinkChaos f48908f7be
Add connectIPVersion to choose how Blocky connects to other hosts (#589)
This impacts both DNS lookups and lists downloading.

Co-authored-by: Dimitri Herzog <dimitri.herzog@gmail.com>
2022-09-19 21:44:12 +02:00
Dan Ponte 465dda9283 Meh, just don't use named returns 2022-09-17 17:31:05 -04:00
Dan Ponte dcec9853d6 Use short return like the rest of the extract functions 2022-09-17 17:29:13 -04:00
Dan Ponte 4fe5344e0f Rename function, reverse return order 2022-09-17 17:26:35 -04:00
ThinkChaos 99edadb992 feat(config): Ignore non regular files when loading from a directory 2022-09-17 16:15:35 -04:00