Skip to content

Commit

Permalink
added tls client configuration for doh and doq
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeffrey Damick authored and mr-karan committed Dec 9, 2023
1 parent 371f014 commit 89224c7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 7 additions & 0 deletions pkg/resolvers/doh.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package resolvers

import (
"bytes"
"crypto/tls"
"encoding/base64"
"fmt"
"io/ioutil"
Expand Down Expand Up @@ -30,8 +31,14 @@ func NewDOHResolver(server string, resolverOpts Options) (Resolver, error) {
if u.Scheme != "https" {
return nil, fmt.Errorf("missing https in %s", server)
}
transport := http.DefaultTransport.(*http.Transport).Clone()
transport.TLSClientConfig = &tls.Config {
ServerName: resolverOpts.TLSHostname,
InsecureSkipVerify: resolverOpts.InsecureSkipVerify,
}
httpClient := &http.Client{
Timeout: resolverOpts.Timeout,
Transport: transport,
}
return &DOHResolver{
client: httpClient,
Expand Down
4 changes: 3 additions & 1 deletion pkg/resolvers/doq.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ type DOQResolver struct {
func NewDOQResolver(server string, resolverOpts Options) (Resolver, error) {
return &DOQResolver{
tls: &tls.Config{
NextProtos: []string{"doq"},
NextProtos: []string{"doq"},
ServerName: resolverOpts.TLSHostname,
InsecureSkipVerify: resolverOpts.InsecureSkipVerify,
},
server: server,
resolverOptions: resolverOpts,
Expand Down

1 comment on commit 89224c7

@trap13star11
Copy link

Choose a reason for hiding this comment

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

Please sign in to comment.