-
Notifications
You must be signed in to change notification settings - Fork 2.4k
make CoreDNS DoH Server #1619
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
make CoreDNS DoH Server #1619
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1619 +/- ##
=========================================
- Coverage 53.44% 52.55% -0.9%
=========================================
Files 186 191 +5
Lines 9392 9590 +198
=========================================
+ Hits 5020 5040 +20
- Misses 3989 4164 +175
- Partials 383 386 +3
Continue to review full report at Codecov.
|
|
Also need a way to for http/2 and the forward and maybe proxy plugin should start speaking it. |
chantra
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
core/dnsserver/doh/https.go
Outdated
| // MimeType is the DoH mimetype that should be used. | ||
| const MimeType = "application/dns-udpwireformat" | ||
|
|
||
| // RequestToMsg extra the dns message from the request body. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: s/extra/extract/
core/dnsserver/doh/https.go
Outdated
|
|
||
| buf, err := ioutil.ReadAll(req.Body) | ||
| if err != nil { | ||
| return nil, nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this return the error?
core/dnsserver/server_https.go
Outdated
| } | ||
|
|
||
| w.Header().Set("Content-Type", doh.MimeType) | ||
| w.Header().Set("Cache-Control", "max-age=0") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe a FIXME to implement cache-control later?
core/dnsserver/doh/https.go
Outdated
| const MimeType = "application/dns-udpwireformat" | ||
|
|
||
| // RequestToMsg extra the dns message from the request body. | ||
| func RequestToMsg(req *http.Request) (*dns.Msg, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note that this only handle POST.
For GET use case, the content-type should be taken from the query parameter ct and the dns payload will be base64safeurl encoded (with trailing = removed) in the dns query parameter. Maybe worth a FIXME/TODO comment.
|
@chantra thanks for reviewing. yes error handling needs to be done - the draft is also light on this. I'll fix things after -04 is released. |
|
@chantra PTAL, address all comments and implemented -08 of the draft. |
|
/cc @johnbelamaric |
johnbelamaric
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor issues, looks good
core/dnsserver/https.go
Outdated
| return nil, fmt.Errorf("no 'dns' query parameter found") | ||
| } | ||
| if len(b64) != 1 { | ||
| return nil, fmt.Errorf("multipe 'dns' query values found") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: s/multipe/multiple/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doine
core/dnsserver/server-https.go
Outdated
| buf, _ := dw.Msg.Pack() | ||
|
|
||
| w.Header().Set("Content-Type", mimeTypeDOH) | ||
| w.Header().Set("Cache-Control", "max-age=128") // Minttl as done in cache. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No control over this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
proper bug filed: #1823
The draft is still debating the exact requirements here, but it is clear what needs to be done. Left TODO with issue number.
|
Great stuff! |
The DoH work (#1619) made changes to pkg/nonwriter.Writer that in hindsight were not backwards compatible; it added override for the LocalAddr() and RemoteAddr(). Instead of rolling back that PR, this PR reverts those changes and creates a DoHWriter for use in the https-server.go side of things. This was only caught in the integration test making this hard to catch, so we add a upstream_file_test.go that tries (doesn't work yet) to test this in the unit tests as well. Esp. helpful when 'git bisecting'. Fixes #1826
The DoH work (#1619) made changes to pkg/nonwriter.Writer that in hindsight were not backwards compatible; it added override for the LocalAddr() and RemoteAddr(). Instead of rolling back that PR, this PR reverts those changes and creates a DoHWriter for use in the https-server.go side of things. This was only caught in the integration test making this hard to catch, so we add a upstream_file_test.go that tries (doesn't work yet) to test this in the unit tests as well. Esp. helpful when 'git bisecting'. Fixes #1826
The DoH work (#1619) made changes to pkg/nonwriter.Writer that in hindsight were not backwards compatible; it added override for the LocalAddr() and RemoteAddr(). Instead of rolling back that PR, this PR reverts those changes and creates a DoHWriter for use in the https-server.go side of things. This was only caught in the integration test making this hard to catch, so we add a upstream_file_test.go that tries (doesn't work yet) to test this in the unit tests as well. Esp. helpful when 'git bisecting'. Fixes #1826
* WIP: make CoreDNS DoH Server * It works * Fix tests * Review from Tom - on diff. PR * correct mime type * Cleanups and use the pkg/nonwriter * rename and updates * implement get * implement GET * Code review comments * correct context * tweaks * code review
The DoH work (coredns#1619) made changes to pkg/nonwriter.Writer that in hindsight were not backwards compatible; it added override for the LocalAddr() and RemoteAddr(). Instead of rolling back that PR, this PR reverts those changes and creates a DoHWriter for use in the https-server.go side of things. This was only caught in the integration test making this hard to catch, so we add a upstream_file_test.go that tries (doesn't work yet) to test this in the unit tests as well. Esp. helpful when 'git bisecting'. Fixes coredns#1826
1. What does this pull request do?
Add experimental DoH support.
2. Which issues (if any) are related?
3. Which documentation changes (if any) need to be made?