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

New Plugin: QUIC proxy [RFC9250] #6245

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

jaehnri
Copy link
Contributor

@jaehnri jaehnri commented Aug 8, 2023

1. Why is this pull request needed and what does it do?

This PR adds support for QUIC proxying in CoreDNS

2. Which issues (if any) are related?

Closes #5583

3. Which documentation changes (if any) need to be made?

README documentation for the plugin was added, but it is possible that there are more places to update.

4. Does this introduce a backward incompatible change or deprecation?

No.

// reached the end of list without any answer
if ret != nil {
// write empty response and finish
w.WriteMsg(ret)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that writing an empty dns message to client would result in client-side parsing/validation errors. I think the proper response id with a SERVFAIL response code, with question correctly set. Returning a servfail and error instead of writing a response would work too (base server code writes an error response to client when ServeDNS returns a SERVFAIL code).

Suggested change
w.WriteMsg(ret)
return dns.RcodeServerFailure, <some-error>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed and fixed. I got this code from the grpc plugin, should we port this fix there too?

// reached the end of list without any answer
if ret != nil {
// write empty response and finish
w.WriteMsg(ret)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we port this fix there too?

Probably, but not in this PR.

@@ -0,0 +1,68 @@
package quic
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This policy selection code has been repeated across several plugins now (forward, grpc, quic). Should we unify it? If so, where should it be? plugin/pkg?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be a good place. Thanks!

@@ -117,6 +121,38 @@ func TestQUICProtocolError(t *testing.T) {
}
}

func TestQUICPlugin(t *testing.T) {
Copy link
Contributor Author

@jaehnri jaehnri Sep 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The plugin integration test ended up in the test folder. Unlike forward, setting up a mock quic server to answer a simple DNS query is not easy because you need not only to create a listener but also accept connections, streams, write, and close to the stream, all manually.

The best way I found to make it work and avoid flakiness was to use the CoreDNSServerAndPorts function to spin up a CoreDNS QUIC server and test the plugin against it.

jaehnri and others added 9 commits September 18, 2023 03:15
Signed-off-by: João Henri <joao.rocha@suse.com>
Also add relevant documentation to QUIC proxy.go

Signed-off-by: João Henri <joao.rocha@suse.com>
Signed-off-by: João Henri <joao.rocha@suse.com>
Signed-off-by: João Henri <joao.rocha@suse.com>
Signed-off-by: jaehnri <joao.henri.cr@gmail.com>
Signed-off-by: jaehnri <joao.henri.cr@gmail.com>
Signed-off-by: jaehnri <joao.henri.cr@gmail.com>
Signed-off-by: jaehnri <joao.henri.cr@gmail.com>
Signed-off-by: jaehnri <joao.henri.cr@gmail.com>
if q.tlsServerName != "" {
q.tlsConfig.ServerName = q.tlsServerName
} else {
q.tlsConfig.InsecureSkipVerify = true

Check failure

Code scanning / CodeQL

Disabled TLS certificate check High

InsecureSkipVerify should not be used in production code.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll have to find a way to circumvent this. quic-go doesn't work without tls.Config and I couldn't set the tls_servername using plugin/tls test certificates.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jaehnri the plugin/dns test certs common name is empty, therefore the hostname cannot match. My suggestion would be to drop the tls_servername option, because it should never be needed (the tls package checks if the common name, subject alternative names or ip addresses contains the hosts name) and instead introduce the option tls_skip_verify. For test cases u can set the common name manually via the tlsConfig

@codecov
Copy link

codecov bot commented Sep 18, 2023

Codecov Report

Attention: Patch coverage is 32.13213% with 226 lines in your changes are missing coverage. Please review.

Project coverage is 57.96%. Comparing base (93c57b6) to head (3fa11dc).
Report is 1152 commits behind head on master.

Files Patch % Lines
plugin/quic/proxy.go 12.82% 102 Missing ⚠️
plugin/quic/quic.go 6.94% 67 Missing ⚠️
plugin/quic/setup.go 66.96% 29 Missing and 8 partials ⚠️
plugin/quic/policy.go 40.00% 18 Missing ⚠️
core/dnsserver/server_quic.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6245      +/-   ##
==========================================
+ Coverage   55.70%   57.96%   +2.26%     
==========================================
  Files         224      256      +32     
  Lines       10016    16868    +6852     
==========================================
+ Hits         5579     9777    +4198     
- Misses       3978     6494    +2516     
- Partials      459      597     +138     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@chrisohaver
Copy link
Member

@jaehnri, What is the state of this PR. Is it pending a final review, or are there parts yet to complete?

@chrisohaver chrisohaver changed the title [RFC9250]: QUIC plugin New Plugin: QUIC proxy [RFC9250] Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support For DoQ (DNS over QUIC)
3 participants