Commit Graph

52 Commits

Author SHA1 Message Date
ThinkChaos d5b6ee93b5 fix: use proxy env vars via Go default HTTP Transport values
Don't build `http.Transport` instances from scratch, but start from
`http.DefaultTransport` and override what is needed.
2024-04-10 09:43:57 -04:00
ThinkChaos 3fcf379df7 refactor(util): make `LogOnError` get the log from a `Context` 2024-03-19 19:10:07 -04:00
ThinkChaos e9a1e8974d feat(api): support client name lookup when querying via the API 2024-01-18 10:46:54 -05:00
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
ThinkChaos a330174949 style(tests): `ShouldNot(Succeed())` -> `Should(HaveOccurred())` 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
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 4e89b44185 fix(util): make `FatalOnError` override `log.Silence` 2023-11-23 08:45:18 -05: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
ThinkChaos d52c598546
fix(tests): properly silence log output (#1259)
* fix(tests): properly silence log output

Using `init` allows it to also work for benchmarks.
And `log.Silence` was sometimes getting overridden by `log.init`.

* squash: fix(server): don't setup the logger again
2023-11-19 17:51:49 -05:00
Kwitsch 6c000090b1
Unit test refactoring & devcontainer enhancement(#1245)
* Whietlist dot imports for test packages

* improved generate-lcov script

* moved mock_call_sequence to helpertest

* removed default config for markdown

* generate seperate lcov.info for each directory

* path fix in lcov generation script

* ginkgo -> v2.13.1

* fixed redundant strings

* added exampleComKey

* added folder name to finish message

* hide lcov.info in devcontainer

* coverage plugin is bugged if lcov file is excluded

* moved all lcov files to coverage folder

* added requested toos #1251
2023-11-15 16:42:53 +01:00
Dimitri Herzog aa9ae0bd63 chore(text): fix ipv6 representation 2023-09-19 19:24:00 +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 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 a2ab7c3ef1
feat: allow hosts file resolver to use a HTTP(S) link or inline block (#884)
Unify the hosts file parsing between the hosts resolver and lists so
the resolver supports more data sources than local files.

Lists' group cache is now re-used if refresh fails.

Also improve lookups in hosts:
Instead of iterating through all hosts+aliases for each A/AAAA query,
we can do a single lookup.
For PTR we search through only the hosts with an IP version that matches
the question. And compare IPs instead of building the reverse DNS name
for each IP in the hosts database.
2023-03-06 19:32:41 -05: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
Kwitsch d4813a6448
feat(queryLog): log instance hostname to distinguish log entries in multi-instance installation(#319) (#756)
* added hostname to util

* added HostnameString

* some leftover debug output?

* added hostname to querylog

* add optional volume mounts to documentation

* changed documentation
2022-11-24 21:39:58 +01:00
Kwitsch 1a46438086 default Architecture = undefined 2022-10-21 23:11:51 +02:00
Kwitsch 5c20f01680 another one 2022-09-23 20:02:03 +02:00
Dimitri Herzog 6772438760
Memory optimization internal blacklist/whitelist cache (#513) (#514) 2022-05-12 12:05:05 +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
ThinkChaos 62c7816ab3
Support of DoH/DoT as bootstrap DNS (#485) 2022-04-22 22:12:35 +02:00
Dimitri Herzog f44fc032f0 cache DNS queries in bootstrap DNS (#454) 2022-03-19 22:56:18 +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 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 ee8f041938 refactoring: generate enums 2021-09-11 21:31:03 +02:00
Dimitri Herzog ea3b5dee50 added test 2021-09-08 22:54:39 +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
Joseph Harnish d8903bc9c5
#203: Added version to web interface. (#195)
* Added more data to template data, and push the version to server.go in the makefile

* moving version and build time to util package, added build time to the web interface

Co-authored-by: Dimitri Herzog <dimitri.herzog@gmail.com>
2021-05-05 22:38:22 +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
Dimitri Herzog fe841455b0 #139: reverse DNS lookup for custom DNS entries 2021-03-09 23:13:05 +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 35e2cd5c42 code refactoring 2021-02-05 23:17:42 +01:00
Dimitri Herzog ead2352a43 code refactoring 2021-02-05 21:55:48 +01:00
Dimitri Herzog 0fd25207d1 introducing event bus, refactorings 2021-01-23 22:29:43 +01:00
Dimitri Herzog 0ec6c8af9c Test rewrite (Ginkgo), Refactorings 2020-05-04 22:20:13 +02:00
Dimitri Herzog e2086c8929 #28: CLI command to perform a DNS query 2020-04-10 17:08:59 +02:00
Dimitri Herzog 432efd1a97 Blocking response entries (deep CNAME inspection #3 and IP black lists #1) 2020-02-13 18:12:59 +01:00