aboutsummaryrefslogtreecommitdiff
path: root/src/net/lookup.go
diff options
context:
space:
mode:
authorMatt Harden <matt.harden@gmail.com>2017-02-20 05:58:55 -0800
committerBrad Fitzpatrick <bradfitz@golang.org>2017-05-12 18:08:12 +0000
commit380aa884b8b2935137eee266d0a44e9083fae71f (patch)
tree9bfc6df0b2812945abbb77dfe7fd505fff93cbe8 /src/net/lookup.go
parent3b5637ff2bd5c03479780995e7a35c48222157c1 (diff)
downloadgo-380aa884b8b2935137eee266d0a44e9083fae71f.tar.gz
go-380aa884b8b2935137eee266d0a44e9083fae71f.zip
net: allow Resolver to use a custom dialer
In some cases it is desirable to customize the way the DNS server is contacted, for instance to use a specific LocalAddr. While most operating-system level resolvers do not allow this, we have the opportunity to do so with the Go resolver. Most of the code was already in place to allow tests to override the dialer. This exposes that functionality, and as a side effect eliminates the need for a testing hook. Fixes #17404 Change-Id: I1c5e570f8edbcf630090f8ec6feb52e379e3e5c0 Reviewed-on: https://go-review.googlesource.com/37260 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/net/lookup.go')
-rw-r--r--src/net/lookup.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/net/lookup.go b/src/net/lookup.go
index 463b374aff..818f91c3dc 100644
--- a/src/net/lookup.go
+++ b/src/net/lookup.go
@@ -107,6 +107,15 @@ type Resolver struct {
// with resolvers that process AAAA queries incorrectly.
StrictErrors bool
+ // Dial optionally specifies an alternate dialer for use by
+ // Go's built-in DNS resolver to make TCP and UDP connections
+ // to DNS services. The provided addr will always be an IP
+ // address and not a hostname.
+ // The Conn returned must be a *TCPConn or *UDPConn as
+ // requested by the network parameter. If nil, the default
+ // dialer is used.
+ Dial func(ctx context.Context, network, addr string) (Conn, error)
+
// TODO(bradfitz): optional interface impl override hook
// TODO(bradfitz): Timeout time.Duration?
}