mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
net: make cgo resolver work more accurately with network parameter
Unlike the go resolver, the existing cgo resolver exchanges both DNS A and AAAA RR queries unconditionally and causes unreasonable connection setup latencies to applications using the cgo resolver. This change adds new argument (`network`) in all functions through the series of calls: from Resolver.internetAddrList to cgoLookupIPCNAME. Benefit: no redundant DNS calls if certain IP version is used IPv4/IPv6 (no `AAAA` DNS requests if used tcp4, udp4, ip4 network. And vice versa: no `A` DNS requests if used tcp6, udp6, ip6 network) Fixes #25947 Change-Id: I39edbd726d82d6133fdada4d06cd90d401e7e669 Reviewed-on: https://go-review.googlesource.com/c/120215 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
fc4f2e5692
commit
c659be4dc8
15 changed files with 110 additions and 44 deletions
|
|
@ -346,7 +346,7 @@ func TestDialParallel(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func lookupSlowFast(ctx context.Context, fn func(context.Context, string) ([]IPAddr, error), host string) ([]IPAddr, error) {
|
||||
func lookupSlowFast(ctx context.Context, fn func(context.Context, string, string) ([]IPAddr, error), network, host string) ([]IPAddr, error) {
|
||||
switch host {
|
||||
case "slow6loopback4":
|
||||
// Returns a slow IPv6 address, and a local IPv4 address.
|
||||
|
|
@ -355,7 +355,7 @@ func lookupSlowFast(ctx context.Context, fn func(context.Context, string) ([]IPA
|
|||
{IP: ParseIP("127.0.0.1")},
|
||||
}, nil
|
||||
default:
|
||||
return fn(ctx, host)
|
||||
return fn(ctx, network, host)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue