diff options
author | Ben Burkert <ben@benburkert.com> | 2017-06-08 13:19:28 -0700 |
---|---|---|
committer | Brad Fitzpatrick <bradfitz@golang.org> | 2017-06-08 21:53:49 +0000 |
commit | d8a7990ffad9aebfb7261df7afb3049da4a09986 (patch) | |
tree | f6fdbc5971109fd6220387507140a50e55251cac /src/net/lookup.go | |
parent | d55d7b93978e1a10b6588962f999d3ebd6d65a3d (diff) | |
download | go-d8a7990ffad9aebfb7261df7afb3049da4a09986.tar.gz go-d8a7990ffad9aebfb7261df7afb3049da4a09986.zip |
net: support all PacketConn and Conn returned by Resolver.Dial
Allow the Resolver.Dial func to return instances of Conn other than
*TCPConn and *UDPConn. If the Conn is also a PacketConn, assume DNS
messages transmitted over the Conn adhere to section 4.2.1. "UDP usage".
Otherwise, follow section 4.2.2. "TCP usage".
Provides a hook mechanism so that DNS queries generated by the net
package may be answered or modified before being sent to over the
network.
Updates #19910
Change-Id: Ib089a28ad4a1848bbeaf624ae889f1e82d56655b
Reviewed-on: https://go-review.googlesource.com/45153
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.go | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/net/lookup.go b/src/net/lookup.go index 818f91c3dc..abc56de533 100644 --- a/src/net/lookup.go +++ b/src/net/lookup.go @@ -111,9 +111,11 @@ type Resolver struct { // 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. + // If the Conn returned is also a PacketConn, sent and received DNS + // messages must adhere to section 4.2.1. "UDP usage" of RFC 1035. + // Otherwise, DNS messages transmitted over Conn must adhere to section + // 4.2.2. "TCP usage". + // If nil, the default dialer is used. Dial func(ctx context.Context, network, addr string) (Conn, error) // TODO(bradfitz): optional interface impl override hook |