net/dns/resolver: make DoH dialer use existing dnscache happy eyeball dialer
Simplify the ability to reason about the DoH dialing code by reusing the dnscache's dialer we already have. Also, reduce the scope of the "ip" variable we don't want to close over. This necessarily adds a new field to dnscache.Resolver: SingleHostStaticResult, for when the caller already knows the IPs to be returned. Change-Id: I9f2aef7926f649137a5a3e63eebad6a3fffa48c0 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:

committed by
Brad Fitzpatrick

parent
e96dd00652
commit
ecea6cb994
@ -5,6 +5,7 @@
|
||||
package resolver
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"net"
|
||||
"reflect"
|
||||
@ -169,6 +170,25 @@ func TestMaxDoHInFlight(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
var testDNS = flag.Bool("test-dns", false, "run tests that require a working DNS server")
|
||||
|
||||
func TestGetKnownDoHClientForProvider(t *testing.T) {
|
||||
var fwd forwarder
|
||||
c, ok := fwd.getKnownDoHClientForProvider("https://dns.google/dns-query")
|
||||
if !ok {
|
||||
t.Fatal("not found")
|
||||
}
|
||||
if !*testDNS {
|
||||
t.Skip("skipping without --test-dns")
|
||||
}
|
||||
res, err := c.Head("https://dns.google/")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer res.Body.Close()
|
||||
t.Logf("Got: %+v", res)
|
||||
}
|
||||
|
||||
func BenchmarkNameFromQuery(b *testing.B) {
|
||||
builder := dns.NewBuilder(nil, dns.Header{})
|
||||
builder.StartQuestions()
|
||||
|
Reference in New Issue
Block a user