Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rewrite support to custom DNS #449

Merged
merged 4 commits into from
Mar 17, 2022

Conversation

ThinkChaos
Copy link
Collaborator

Main commit message:

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.

I use this feature to have an alternative way of spelling my domain which is a bit long.
Comes in handy when manually poking around.

Also did some smaller changes to tests such as unifying MockResolver and resolverMock.

@codecov
Copy link

codecov bot commented Mar 4, 2022

Codecov Report

Merging #449 (dc9ccd5) into development (6d33ec7) will increase coverage by 1.30%.
The diff coverage is 97.59%.

Impacted file tree graph

@@               Coverage Diff               @@
##           development     #449      +/-   ##
===============================================
+ Coverage        94.26%   95.57%   +1.30%     
===============================================
  Files               33       35       +2     
  Lines             2722     2780      +58     
===============================================
+ Hits              2566     2657      +91     
+ Misses             118       85      -33     
  Partials            38       38              
Impacted Files Coverage Δ
resolver/rewriter_resolver.go 96.66% <96.66%> (ø)
config/config.go 88.51% <100.00%> (ø)
resolver/blocking_resolver.go 98.41% <100.00%> (ø)
resolver/conditional_upstream_resolver.go 100.00% <100.00%> (ø)
resolver/custom_dns_resolver.go 100.00% <100.00%> (ø)
resolver/noop_resolver.go 100.00% <100.00%> (ø)
resolver/parallel_best_resolver.go 100.00% <100.00%> (ø)
resolver/resolver.go 100.00% <100.00%> (ø)
server/server.go 89.22% <100.00%> (ø)
redis/redis.go 90.78% <0.00%> (+23.02%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6d33ec7...dc9ccd5. Read the comment docs.

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.
@ThinkChaos ThinkChaos force-pushed the feat/custom-rewrite branch from 38c27f3 to dc9ccd5 Compare March 7, 2022 01:42
@ThinkChaos
Copy link
Collaborator Author

Force pushed to fix Configuration() output.
The failed test looks random and unrelated: I haven't seen this in any previous CI or local run.

@0xERR0R 0xERR0R added this to the 0.19 milestone Mar 17, 2022
@0xERR0R 0xERR0R added the 🔨 enhancement New feature or request label Mar 17, 2022
@0xERR0R
Copy link
Owner

0xERR0R commented Mar 17, 2022

Thanks for your work. It looks good. 👍

@0xERR0R 0xERR0R merged commit f8b6e59 into 0xERR0R:development Mar 17, 2022
@kwitsch kwitsch mentioned this pull request Oct 28, 2022
@ThinkChaos ThinkChaos deleted the feat/custom-rewrite branch January 24, 2023 00:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔨 enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants