summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/miekg/dns/client.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/miekg/dns/client.go')
-rw-r--r--vendor/github.com/miekg/dns/client.go28
1 files changed, 9 insertions, 19 deletions
diff --git a/vendor/github.com/miekg/dns/client.go b/vendor/github.com/miekg/dns/client.go
index 6aa4235d1..dd6b512af 100644
--- a/vendor/github.com/miekg/dns/client.go
+++ b/vendor/github.com/miekg/dns/client.go
@@ -12,15 +12,16 @@ import (
"io/ioutil"
"net"
"net/http"
- "net/url"
"strings"
"time"
)
-const dnsTimeout time.Duration = 2 * time.Second
-const tcpIdleTimeout time.Duration = 8 * time.Second
+const (
+ dnsTimeout time.Duration = 2 * time.Second
+ tcpIdleTimeout time.Duration = 8 * time.Second
-const dohMimeType = "application/dns-udpwireformat"
+ dohMimeType = "application/dns-message"
+)
// A Conn represents a connection to a DNS server.
type Conn struct {
@@ -88,11 +89,10 @@ func (c *Client) Dial(address string) (conn *Conn, err error) {
// create a new dialer with the appropriate timeout
var d net.Dialer
if c.Dialer == nil {
- d = net.Dialer{}
+ d = net.Dialer{Timeout:c.getTimeoutForRequest(c.dialTimeout())}
} else {
d = net.Dialer(*c.Dialer)
}
- d.Timeout = c.getTimeoutForRequest(c.writeTimeout())
network := "udp"
useTLS := false
@@ -214,17 +214,7 @@ func (c *Client) exchangeDOH(ctx context.Context, m *Msg, a string) (r *Msg, rtt
return nil, 0, err
}
- // TODO(tmthrgd): Allow the path to be customised?
- u := &url.URL{
- Scheme: "https",
- Host: a,
- Path: "/.well-known/dns-query",
- }
- if u.Port() == "443" {
- u.Host = u.Hostname()
- }
-
- req, err := http.NewRequest(http.MethodPost, u.String(), bytes.NewReader(p))
+ req, err := http.NewRequest(http.MethodPost, a, bytes.NewReader(p))
if err != nil {
return nil, 0, err
}
@@ -232,8 +222,6 @@ func (c *Client) exchangeDOH(ctx context.Context, m *Msg, a string) (r *Msg, rtt
req.Header.Set("Content-Type", dohMimeType)
req.Header.Set("Accept", dohMimeType)
- t := time.Now()
-
hc := http.DefaultClient
if c.HTTPClient != nil {
hc = c.HTTPClient
@@ -243,6 +231,8 @@ func (c *Client) exchangeDOH(ctx context.Context, m *Msg, a string) (r *Msg, rtt
req = req.WithContext(ctx)
}
+ t := time.Now()
+
resp, err := hc.Do(req)
if err != nil {
return nil, 0, err