Commit Graph

56 Commits

Author SHA1 Message Date
Dimitri Herzog daf3b029c8
chore: update golangci-lint (#1495) 2024-05-26 17:54:22 +02:00
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 b335887992 refactor(log): store log in context so it's automatically propagated 2024-03-19 19:10:07 -04:00
ThinkChaos ad1ef0bcfb fix: don't use upstream `ServFail` responses besides forwarding them
Don't consider `ServFail` as a TCP/UDP race win.
Use an error to also make sure we don't, for instance, cache such
responses.
2024-01-27 17:25:33 -05:00
ThinkChaos df8c373ef1 feat(resolver): race UDP and TCP when connecting upstream
Inspired by https://en.wikipedia.org/wiki/Happy_Eyeballs this should
improve latency and fixes the long standing behavior where a single
resolve attempt could take 2x the timeout.
UpstreamResolver.Resolve can still take more than the configured timeout
so maybe that can be improved by splitting the retry algorithm into its
own resolver type.
2023-12-19 10:44:19 -05:00
ThinkChaos 29a5681b3c refactor(bootstap): prepare for resolver package split 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 603d374405 refactor: remove no longer needed TLS handshake timeout
Since the whole resolve has a context w/ deadline it's no longer needed.
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 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
ThinkChaos 2c71f91aca refactor: remove deprecated and no-op `SingleInflight` 2023-11-21 12:21:35 -05:00
ThinkChaos eae99ec550 refactor: make use of contexts in more places
- `CacheControl.FlushCaches`
- `Querier.Query`
- `Resolver.Resolve`

Besides all the API churn, this leads to `ParallelBestResolver`,
`StrictResolver` and `UpstreamResolver` simplification: timeouts only
need to be setup in one place, `UpstreamResolver`.

We also benefit from using HTTP request contexts, so if the client
closes the connection we stop processing on our side.
2023-11-21 12:21:35 -05: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 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 de9acd3849
feat: add upstream string to resolve error (#902) 2023-02-28 16:22:27 +01:00
ThinkChaos 7c76836373 feat: stack log prefixes to differentiate between log emitters
The goal is to be able to tell apart logs from difference sources, such
as `bootstrap.parallel_best_resolver` and `parallel_best_resolver`.
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
ThinkChaos 164e398d04 fix(resolver): upstream long retry delay
Default delay is 100ms which is way too much for query retries.
2022-12-09 11:23:28 -05:00
ThinkChaos d501d867df style(resolver): standardize configuration disabled impls and tests 2022-12-04 20:59:12 -05:00
ThinkChaos c06c017a1a fix: `startVerifyUpstream` not disabling all start checks 2022-12-02 12:56:44 -05: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 d8c36063b0 fix: format ipv6 URL for DoH bootstrap request according to RFC3513 (#701) 2022-11-04 08:29:16 +01: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
Dimitri Herzog 421807fc22
chore: update golangci-lint (#631) 2022-08-19 22:04:35 +02:00
Dimitri Herzog 3b620102a7
set host header for DoH requests (#580) 2022-06-29 21:39:39 +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 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 cdec99567a updated retry-go 2021-12-24 22:40:06 +01:00
Dimitri Herzog 4b85eedc86 Replace retry implementation with retry-go 2021-12-13 22:10:14 +01:00
Dimitri Herzog ae9b12f15a Configurable upstream lookup timeout (#256) 2021-09-19 22:49:38 +02:00
Dimitri Herzog ee8f041938 refactoring: generate enums 2021-09-11 21:31:03 +02:00
Dimitri Herzog 63735546bb moving model types to the separate package 2021-09-08 21:38:34 +02:00
Dimitri Herzog 919512959b use full-qualified name as module 2021-08-27 13:41:36 +02:00
Dimitri Herzog 850baf0e47
bootstrapDNS not used for upstream DNS resolution (#242) (#246) 2021-08-21 23:19:30 +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 b454a17c0b #162: Segmentation fault on TCP request with UDP fallback 2021-03-14 22:11:01 +01:00
Dimitri Herzog eaa4e30db4 update golangci-lint, fixint lint errors 2021-03-05 22:52:22 +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 0fd25207d1 introducing event bus, refactorings 2021-01-23 22:29:43 +01:00
Dimitri Herzog 2d4d26f432 Fixes #87: Error after upgrading to 0.9 2020-07-08 21:55:47 +02:00
Dimitri Herzog 0cb0b43089 go mod tidy 2020-06-21 23:07:24 +02:00