Commit Graph

171 Commits

Author SHA1 Message Date
ThinkChaos 795f3ddf93
fix: configuration for FQDN only resolver (#1025) 2023-05-15 10:24:07 -04:00
mandrav 015b565137
Add maxErrorsPerFile blocking configuration (#986)
* 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>
2023-04-12 20:43:49 +02:00
Kwitsch 68a8476e48
chore(build): Automation workflows (#972)
* 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
2023-04-03 16:33:16 +02:00
ThinkChaos 9b15e4807e fix: log `startStrategy` instead of deprecated `failStartOnListError` 2023-03-29 10:07:04 -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
Dimitri Herzog 65137b4514 test(bootstrap): add test case 2023-01-18 18:57:55 +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 3e95b12eed feat: caching for empty DNS responses (#700) 2022-11-08 21:45:28 +01:00
Dimitri Herzog a5ef595f43 fix: change network names (#703) 2022-11-02 21:58:58 +01:00
Dimitri Herzog 177c20fb96 update: github.com/abice/go-enum 2022-10-10 21:46:53 +02: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
ThinkChaos d2064ef986 feat(config): Ignore non YAML files when loading from a directory 2022-09-17 15:59:43 -04:00
Dan Ponte af5d2301b6 Fix lint 2022-09-17 15:38:47 -04:00
Dan Ponte 81344f714c Address code review concerns 2022-09-17 15:34:34 -04:00
Dan Ponte 6325c3fc63 Test reflects common use case 2022-09-15 13:29:15 -04:00
Dan Ponte 736753737c Add config test 2022-09-15 13:02:25 -04:00
Dan Ponte 46deb2f780 Add ability to specify certificate common name. 2022-09-14 22:03:15 -04: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
FileGo b49695fad3 Added config, simplified check for loopback 2022-08-23 07:54:03 +01:00
FileGo 377f4764fe
Enable start as long as at least one upstream resolver in group is reachable (#608)
* 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>
2022-08-21 17:21:08 +02:00
Dimitri Herzog 421807fc22
chore: update golangci-lint (#631) 2022-08-19 22:04:35 +02:00
Kwitsch 9c80a5f9a9
test: use dynamic unit test data (#624) 2022-08-06 22:44:26 +02:00
Kwitsch 5e9eaa2965
delivery of blocking group as EDNS error(560) (#611) 2022-08-06 22:30:26 +02:00
Dimitri Herzog 3c5b7a20dc
chore: Managing of external tools with go modules (#616) (#617) 2022-08-03 22:10:07 +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
Adyanth H 31cf8c77d5
Add fallbackUpstream for conditional mapping (#593) 2022-07-11 08:06:42 +02:00
Dimitri Herzog b048bb051f
test: Fix race condition in test (#567)
* use ginkgo with repeat temporarily

* use lock for setting config

* Revert "use ginkgo with repeat temporarily"

This reverts commit 9a25b4e26f.
2022-06-20 22:55:31 +02:00
Kwitsch c912356740
Option to handle FQDN only requests (#561) 2022-06-20 13:02:51 +02:00
Peter Dave Hello e6957a3ff8
Make DoH/DoT server mininum TLS version configurable (#546)
* Make DoH/DoT server mininum TLS version configurable

* Disable gosec lint on server TLSConfig
2022-06-04 08:23:40 +02:00
FileGo 92fd6235bf
Self-signed certificate generation (#532)
* Added self-signed certificate functionality

Co-authored-by: Dimitri Herzog <dimitri.herzog@gmail.com>
2022-05-27 22:20:44 +02:00
FileGo 0731ebe18a
Support for multiple configuration files (#534) 2022-05-25 15:13:52 +02:00
FileGo 776c51fc59
Adds user customizable DoH upstream user agent (#525)
* Adds user customizable DoH upstream user agent

* Changed default user agent to empty
2022-05-18 08:49:15 +02:00
Dimitri Herzog 3392de0e16
Cache refresh memory consumption optimization (#470) (#515) 2022-05-16 21:32:16 +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 53814a2208
chore: refactoring list cache, extracting download functionality (#508) 2022-05-06 17:57:33 +02:00
ThinkChaos 62c7816ab3
Support of DoH/DoT as bootstrap DNS (#485) 2022-04-22 22:12:35 +02:00
Dimitri Herzog 28789ee7fe
filtering of queries (#450) (#474) 2022-04-01 08:58:09 +02:00
Dimitri Herzog d1289e8452 removed deprecated configuration parameters 2022-03-28 21:48:49 +02:00
Dimitri Herzog 476dd7d0eb update go-enum to v0.4.0 2022-03-28 21:35:48 +02:00
Dimitri Herzog 78376058c2 test: added unmarshalling tests 2022-03-25 22:04:26 +01:00
Dimitri Herzog 2bb2f97f8f
CustomDNS: parameter "filterUnmappedTypes" to allow/disable forwarding to the upstream resolver (#467) 2022-03-22 22:15:31 +01: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
FileGo c176b02ac9
Support Postgresql database for query log (#348)
Co-authored-by: Dimitri Herzog <dimitri.herzog@gmail.com>
2022-01-07 21:42:06 +01:00
FileGo b43c7aa2cb
Enable resolving hosts file (#362)
fixes #362 

Co-authored-by: Dimitri Herzog <dimitri.herzog@gmail.com>
2022-01-04 15:40:09 +01:00
Dimitri Herzog ccc6f888e3 externalize retry parameters for query log 2021-12-21 22:03:02 +01:00
Kwitsch d3611fb444
FR: DNS cache sync between multiple blocky instances (#344) (#365) 2021-12-21 17:06:16 +01:00
Dimitri Herzog 68cc391e0d typo 2021-12-20 22:37:50 +01:00
ThinkChaos 69dc38308c
Allow configuring multiple listen addresses for each port (#372) 2021-12-20 22:13:07 +01:00
ThinkChaos cbcd09c898
Allow configuring custom DNS TTL (#370) 2021-12-16 21:38:01 +01:00
Dimitri Herzog c88ca4af85 Improve error message for wrong upstream definition #356 2021-12-11 22:28:44 +01:00
Kwitsch 2f79086742
Make retry for list download configurable (#308) (#338)
* DownloadAttempts & DownloadCooldown added to BlockingConfig

* implementation of downloadAttempts & downloadCooldown

* extended NewListCache call

* unit test fix(use old default values)

* documentation of downloadAttempts & downloadCooldown

* linter error(line length)
2021-11-14 21:34:09 +01:00
FileGo 98cf484517
Option to disable the query log (#333) 2021-11-10 21:54:32 +01:00
Dimitri Herzog 9b9596970c Improved configuration output (duration format, etc.) 2021-11-07 21:35: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 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
Dimitri Herzog c22292eb19 DoT (DNS-over-TLS) server (#303) 2021-10-04 21:56:18 +02:00
Dimitri Herzog 9b6dc667f9 Ipv6 parsing error in upstream definition (#285) 2021-09-29 22:41:47 +02:00
Dimitri Herzog ae9b12f15a Configurable upstream lookup timeout (#256) 2021-09-19 22:49:38 +02:00
Dimitri Herzog 925c6f97eb Make list download timeout configurable (#254) 2021-09-15 07:41:20 +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 dca82623a1 Storing the query log in the database (#258) 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
Dimitri Herzog 6a3baa5b95 obfuscate log output for user sensitive data to increase privacy (#225) 2021-08-23 22:34:48 +02:00
Dimitri Herzog 850baf0e47
bootstrapDNS not used for upstream DNS resolution (#242) (#246) 2021-08-21 23:19:30 +02:00
Dimitri Herzog 447821f646
Unable to set IP for http/https port (#221) (#226)
#221: Unable to set IP for http/https port
2021-06-28 07:51:46 +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
Dimitri Herzog 209024ed0b
#81: Configuration of different upstream DNS servers for different clients (#193)
#81: Configuration of different upstream DNS servers for different clients
2021-04-22 22:37:59 +02:00
Dimitri Herzog db64fc3f03 #182: disabled linting of config structure 2021-04-17 22:25:17 +02:00
Joseph Harnish 1ea60579a7
#182 - added config option for logTimestamp (#184)
* added config option for logTimestamp

* set default to be true
2021-04-17 22:23:51 +02:00
moyo 000bebafb3
Add support of disbale ipv6(AAAA) query (#171)
Add support of disbale ipv6(AAAA) query
2021-04-06 21:34:10 +02:00
Dimitri Herzog 399e8416aa #128: Domain rewrite in conditional resolver 2021-03-10 22:59:04 +01:00
Dimitri Herzog 5fe8bf95af #139: Multiple IP addresses for Custom DNS 2021-03-07 22:50:47 +01:00
Dimitri Herzog eaa4e30db4 update golangci-lint, fixint lint errors 2021-03-05 22:52:22 +01:00
Dimitri Herzog efb5ac37af #147: Blocky commands do not run without local ./config.yml file 2021-02-26 22:42:00 +01:00
Dimitri Herzog 21f9b90841 go fmt 2021-02-26 21:39:41 +01:00
donald-art 7ee2e7db64
public API documentation (#146)
* added doc comments

* added doc comments

* added doc comments

* added doc comments

* added doc comments

* added doc comments

* added doc comments

* added doc comments

* added doc comments

* added doc comments

* added doc comments

* added doc comments

* added doc comments

* added doc comments

* added doc comments

* added doc comments

* added doc comments

* added doc comments

* added doc comments

* added doc comments

* added doc comments

* added doc comments

* added doc comments

* added doc comments

* added doc comments

* added doc comments

* added doc comments
2021-02-26 13:45:57 +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
nicolas-martin 3b0bbc5f6b use package logger instead of global 2021-02-22 17:28:48 -05:00
Dimitri Herzog 2d11aa13cb removed unreachable conditions 2021-02-08 22:59:01 +01:00
Dimitri Herzog 8a6884d3e8 improved port conversion 2021-02-04 22:27:02 +01:00
Dimitri Herzog e9fff3cef1 prefetching of often used queries 2021-01-16 22:24:05 +01:00
Dimitri Herzog 914a04e5b1 #79: Support for multiple conditional forwarders per domain 2020-12-27 23:40:27 +01:00
Dimitri Herzog 694fe646f6 #116: optional bind address for DNS port 2020-12-27 22:04:01 +01:00