plugin/forward: added support for per-nameserver TLS SNI#7633
Merged
yongtang merged 3 commits intoOct 27, 2025
Conversation
While keeping backward compatibility, I added support for per-nameserver TLS servername specification. This enables users to use upstream dns-over-tls servers from different providers, presenting different certificates. Added tests and updated documentation. Signed-off-by: Endre Szabo <git@end.re>
Signed-off-by: Endre Szabo <git@end.re>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #7633 +/- ##
==========================================
+ Coverage 55.70% 63.26% +7.56%
==========================================
Files 224 278 +54
Lines 10016 15128 +5112
==========================================
+ Hits 5579 9571 +3992
- Misses 3978 4871 +893
- Partials 459 686 +227 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Contributor
Author
|
I've no idea why that test case fails, I checked out the PR branch on an amd64 Linux (was developing on a Mac) and the same Golang version with the same commands the CI use run just fine. |
Signed-off-by: Endre Szabo <git@end.re>
yongtang
approved these changes
Oct 27, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
While keeping backward compatibility, I added support for per-nameserver TLS servername specification. This enables users to use upstream dns-over-tls servers from different providers, each presenting different X.509 certificates.
Added tests and updated documentation.
1. Why is this pull request needed and what does it do?
This PR enable users to use upstream nameservers from different dns-over-tls providers. Formerly, plugin only supported a plugin-wide specification of expected TLS server name. With these changes every tls URI in the
TOfield can have the expected server name specified. Very much like how unbound does it:Using unbound:
Using CoreDNS with forward:
I had to use
%instead of#or@because other stanzas would either be stripped (as being a comment by Caddy controller) or treaded as part of the IP address. I revamped the use of the zone filter to be a zone splitter instead, making us able to use the%as delimiter.One
tls.Configis instantiated per SNI, each with thetls.NewLRUClientSessionCachecapacity set to the number of proxies addressing said SNI. This verytls.Configgets assigned to every respective proxy addressing the same upstream provider.Former global way of using
tls_servernameand using this new method is mutually exclusive. Doing so will result in a config parsing error. For backward compatibilitytls_servernamestill can be used, given that no per-nameserver SNI is specified.2. Which issues (if any) are related?
This PR addresses at least #6059.
3. Which documentation changes (if any) need to be made?
I updated the documentation of the forward plugin, practically no other documentation needs to be updated.
4. Does this introduce a backward incompatible change or deprecation?
No.