mirror of
				https://github.com/golang/go.git
				synced 2025-11-04 02:30:57 +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
				
			
		| 
						 | 
				
			
			@ -15,7 +15,7 @@ import (
 | 
			
		|||
func TestCgoLookupIP(t *testing.T) {
 | 
			
		||||
	defer dnsWaitGroup.Wait()
 | 
			
		||||
	ctx := context.Background()
 | 
			
		||||
	_, err, ok := cgoLookupIP(ctx, "localhost")
 | 
			
		||||
	_, err, ok := cgoLookupIP(ctx, "ip", "localhost")
 | 
			
		||||
	if !ok {
 | 
			
		||||
		t.Errorf("cgoLookupIP must not be a placeholder")
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -28,7 +28,7 @@ func TestCgoLookupIPWithCancel(t *testing.T) {
 | 
			
		|||
	defer dnsWaitGroup.Wait()
 | 
			
		||||
	ctx, cancel := context.WithCancel(context.Background())
 | 
			
		||||
	defer cancel()
 | 
			
		||||
	_, err, ok := cgoLookupIP(ctx, "localhost")
 | 
			
		||||
	_, err, ok := cgoLookupIP(ctx, "ip", "localhost")
 | 
			
		||||
	if !ok {
 | 
			
		||||
		t.Errorf("cgoLookupIP must not be a placeholder")
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue