Commit Graph

293 Commits

Author SHA1 Message Date
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
ThinkChaos add591c5a4
fix(ede-resolver): don't panic when next resolver errors (#778) 2022-12-02 10:10:11 +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
Dimitri Herzog 3e95b12eed feat: caching for empty DNS responses (#700) 2022-11-08 21:45:28 +01:00
Dimitri Herzog d8c36063b0 fix: format ipv6 URL for DoH bootstrap request according to RFC3513 (#701) 2022-11-04 08:29:16 +01:00
Kwitsch fdb09bb902 more flaky fixes 2022-09-24 00:02:58 +02:00
Kwitsch 3dc6cb33f9 flaky fixes 2022-09-23 23:42:18 +02:00
Kwitsch 0eadfc6bf6 fix flaky race test 2022-09-23 23:26:08 +02:00
Kwitsch d93ed9c3c7 refactoring 2022-09-23 23:07:54 +02:00
Kwitsch 93e1e32582 Merge branch 'fb-635' of https://github.com/kwitsch/blocky-dev into fb-635
# Conflicts:
#	resolver/sudn_resolver.go
2022-09-23 22:58:35 +02:00
Kwitsch 9784134ab7 moved newResponseMsg & returnResponseModel to resolver.go 2022-09-23 22:56:40 +02:00
Kwitsch ebe284dbdd
Merge branch 'development' into fb-635 2022-09-20 21:01:48 +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
Kwitsch fa75c9d44b
fixed typo
Co-authored-by: ThinkChaos <ThinkChaos@users.noreply.github.com>
2022-09-18 14:26:01 +02:00
Dan Ponte 81344f714c Address code review concerns 2022-09-17 15:34:34 -04:00
Dan Ponte d889419f67 No intermediate 2022-09-15 13:09:50 -04:00
Dan Ponte 46deb2f780 Add ability to specify certificate common name. 2022-09-14 22:03:15 -04:00
Kwitsch ba8fe266d5 mdns leakage block 2022-09-14 08:44:17 +02:00
Kwitsch 4f4d97c2eb added RFC6762 & did some refactoring 2022-09-13 19:56:50 +02:00
Kwitsch 2da657f1da linter 2022-09-10 14:10:51 +02:00
Kwitsch cf84241e48 added IPv4loopback var 2022-09-10 04:05:14 +02:00
Kwitsch e3b6810b8b
use IPv6loopback instead reparsing it
Co-authored-by: ThinkChaos <ThinkChaos@users.noreply.github.com>
2022-09-10 04:01:07 +02:00
Kwitsch b50d7c664f
removed debugging code
Co-authored-by: ThinkChaos <ThinkChaos@users.noreply.github.com>
2022-09-10 03:56:52 +02:00
Kwitsch e65a615418 Merge branch 'development' into fb-635 2022-09-09 21:11:15 +02:00
Kwitsch 2f7a30a3b9 rename SudnResolver to SpecialUseDomainNamesResolver 2022-09-09 21:02:01 +02:00
Kwitsch 156f068ace removed configuration output 2022-09-06 21:45:08 +02:00
Kwitsch d809b680aa refactoring 2022-09-06 21:33:48 +02:00
Kwitsch 0d225114ae added SetReply 2022-09-06 21:22:17 +02:00
Kwitsch a0453a733b added unit tests 2022-09-04 01:27:24 +02:00
Kwitsch 6bb3c060e8 finish sudn resolver 2022-09-04 01:27:13 +02:00
Dimitri Herzog 48dbc5bc13 update: github.com/onsi/gomega 2022-09-03 23:43:26 +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 f303d9cab1 sudnLocalhost 2022-09-02 19:52:16 +02:00
Kwitsch baf221cf44 added SudnResolver 2022-08-27 00:00:48 +02:00
Kwitsch 2596f922f5 added ResponseTypeSPECIAL to convertToExtendedErrorCode 2022-08-26 23:59:46 +02:00
FileGo b49695fad3 Added config, simplified check for loopback 2022-08-23 07:54:03 +01:00
FileGo 7ce875f105 Filter loopback addresses from hosts file 2022-08-22 09:28:55 +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
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 3b620102a7
set host header for DoH requests (#580) 2022-06-29 21:39:39 +02:00
Kwitsch c912356740
Option to handle FQDN only requests (#561) 2022-06-20 13:02:51 +02:00
Dimitri Herzog fd8c61c57c improved LRU cache operations (avoid write lock on TotalCount) 2022-06-02 22:58:52 +02:00
FileGo 8bb4f73a38
Removed net.Error.Temporary (#536) 2022-05-27 22:22:00 +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
Peter Dave Hello 4690ed89a9
Hide DoH client http header "User-Agent", fix #446 (#518) 2022-05-17 08:55:29 +02:00
Dimitri Herzog 2994e2a301
add additional logging context (#482) (#516) 2022-05-16 21:42:18 +02:00
Peter Dave Hello 63cfabac7b
Enable "ForceAttemptHTTP2" for DoH upstreamClient (#519)
According to https://pkg.go.dev/net/http#Transport, when TLSClientConfig
is provided, HTTP/2 will be disabled. Setting this option to true, when
using custom TLS config, will still attempt HTTP/2 upgrades.
2022-05-16 21:35:43 +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 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 53814a2208
chore: refactoring list cache, extracting download functionality (#508) 2022-05-06 17:57:33 +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 28789ee7fe
filtering of queries (#450) (#474) 2022-04-01 08:58:09 +02:00
Dimitri Herzog 27f9c8b9a0 chore: improved error logging 2022-03-31 22:29:36 +02:00
Dimitri Herzog 81b896a01d chore: increased test timeout 2022-03-31 22:27:45 +02: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
Dimitri Herzog f9369d8fe0 Use full qualified client name as group name (#329) 2022-02-22 10:55:26 +01:00
Dimitri Herzog 759f55d89c
Rewrite DNS response cache (#378) (#413) 2022-01-20 16:45:29 +01:00
Kwitsch 8921a16433
[Feature] Conditional forwarding of all queries for unqualified hostnames (#363) (#409) 2022-01-19 22:26:39 +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
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 cdec99567a updated retry-go 2021-12-24 22:40:06 +01:00
Dimitri Herzog d7bf373b52 Replace all sleeps in tests with "eventually" from gomega (#379) 2021-12-22 22:21:04 +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 61ca25c64c sanitize log output 2021-12-20 22:37:32 +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 4b85eedc86 Replace retry implementation with retry-go 2021-12-13 22:10:14 +01:00
Dimitri Herzog 9b4752442e Retry to establish db connection for query log (#351) 2021-12-13 22:10:14 +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
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 e882fa0a39
Fallback when using mysql or file as query log (#318) (#336) 2021-11-11 08:52:21 +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 c5c35015cf changed order in client names resolving 2021-10-18 22:44:11 +02:00
Dimitri Herzog 2aed746d2f introduced "failStartOnListError" parameter (#310) 2021-10-14 21:53:54 +02:00
Dimitri Herzog a90fb5d1c2
Extract client name from the URL (DoH and DoT) (#317)
* Extract client name from the URL (DoH and DoT) #304

* improved tests
2021-10-13 22:47:14 +02:00
Dimitri Herzog cd767960a5 introduced go-multierror to handle multiple errors 2021-10-13 22:45:32 +02:00
Dimitri Herzog 57036aa088 fixed golangci-lint issues 2021-10-13 21:40:18 +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 c2fb389cf7 Improve caching of prefetched domains (#290) 2021-09-27 22:52:37 +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 43bd5684a1 Remove stats resolver (#266) 2021-09-13 22:32:34 +02:00
Dimitri Herzog e6ca89607a write database entries async in bulk 2021-09-13 22:06:21 +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 d318e2cddd renamed IPv6Checker to IPV6DisablingResolver 2021-09-09 21:44:49 +02:00
Dimitri Herzog dca82623a1 Storing the query log in the database (#258) 2021-09-08 21:38:34 +02:00
Dimitri Herzog 63735546bb moving model types to the separate package 2021-09-08 21:38:34 +02:00
Gonzalo Arreche c866b71860 Fix go lint issues 2021-09-07 08:34:00 +02:00
Dimitri Herzog eafecf01a3 fixed golint issue 2021-09-06 21:55:12 +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 48a3802b06 Request duration metric is not populated if request resolution was faulty (#257) 2021-08-30 21:43:21 +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 29c0352a05 #235: customDNS resolver should return NOERROR instead of NXDOMAIN for existing domain mapping 2021-07-30 22:31:37 +02:00
Dimitri Herzog fb26cb70e3
Fix "misuse of unbuffered os.Signal channel as argument to signal.Notify (govet)" (#215) 2021-05-28 09:30:26 +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
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
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 314922a028 #111: allow the ability to enable/disable blocking by group 2021-04-28 22:38:23 +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
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
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
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 46cd15b0fd #163: Critical information missing in log entry for DNS error 2021-03-30 21:49:12 +02:00
Dimitri Herzog 6f5384650e #165: Block additional DNS record types 2021-03-26 22:30:48 +01:00
Dimitri Herzog b454a17c0b #162: Segmentation fault on TCP request with UDP fallback 2021-03-14 22:11:01 +01:00
Dimitri Herzog 399e8416aa #128: Domain rewrite in conditional resolver 2021-03-10 22:59:04 +01:00
Dimitri Herzog fe841455b0 #139: reverse DNS lookup for custom DNS entries 2021-03-09 23:13:05 +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 59c650ff6a added/changed some comments 2021-02-26 21:44:53 +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 b043849159 command package refactoring 2021-02-08 22:00:11 +01:00
Dimitri Herzog 35e2cd5c42 code refactoring 2021-02-05 23:17:42 +01:00
Dimitri Herzog 8a6884d3e8 improved port conversion 2021-02-04 22:27:02 +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 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 804bdba9f9 updated dependencies 2020-11-22 22:59:44 +01:00
Dimitri Herzog aacf8532a5
#94 additional cache metrics (#110) 2020-11-18 22:31:05 +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 d19dd7d45e Added new lines 2020-07-08 21:56:09 +02:00
Dimitri Herzog 2d4d26f432 Fixes #87: Error after upgrading to 0.9 2020-07-08 21:55:47 +02:00
Dimitri Herzog 110c14598d Fixes #83: Warning when requesting from the same machine 2020-07-05 22:12:41 +02:00
Dimitri Herzog 0cb0b43089 go mod tidy 2020-06-21 23:07:24 +02:00
Dimitri Herzog d1b3b929e4 #67: consider request protocol TCP/UDP on calling external DNS (AXFR fails most times) 2020-06-21 22:38:04 +02:00
Dimitri Herzog 3d32730608 fmt imports 2020-05-24 22:47:46 +02:00