diff --git a/client.go b/client.go index c52eec1d..5ec07f6a 100644 --- a/client.go +++ b/client.go @@ -12,7 +12,6 @@ import ( "io/ioutil" "net" "net/http" - "net/url" "strings" "time" ) @@ -216,17 +215,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 } @@ -234,8 +223,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 @@ -245,6 +232,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 diff --git a/client_test.go b/client_test.go index 99fb08ae..020e141b 100644 --- a/client_test.go +++ b/client_test.go @@ -590,7 +590,7 @@ func TestConcurrentExchanges(t *testing.T) { } func TestDoHExchange(t *testing.T) { - const addrstr = "dns.cloudflare.com:443" + const addrstr = "https://dns.cloudflare.com/dns-query" m := new(Msg) m.SetQuestion("miek.nl.", TypeSOA)