]> Cypherpunks repositories - gostls13.git/commitdiff
net: add addrList
authorMikio Hara <mikioh.mikioh@gmail.com>
Fri, 30 Aug 2013 00:28:26 +0000 (09:28 +0900)
committerMikio Hara <mikioh.mikioh@gmail.com>
Fri, 30 Aug 2013 00:28:26 +0000 (09:28 +0900)
This CL adds a new type addrList that will carry a short list of IP
addresses to dial helper functions in the upcoming CLs.

This is in preparation for TCP connection setup with fast failover on
dual IP stack node as described in RFC 6555.

Update #3610
Update #5267

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13241046

src/pkg/net/ipsock.go

index 10a51f490d473cbf64340b7419a07701038d8f9e..20407872d77bb8a61852919b647b963b50f6295c 100644 (file)
@@ -40,6 +40,24 @@ type netaddr interface {
        toAddr() Addr
 }
 
+// An addrList represents a list of network endpoint addresses.
+type addrList []netaddr
+
+func (al addrList) toAddr() Addr {
+       switch len(al) {
+       case 0:
+               return nil
+       case 1:
+               return al[0].toAddr()
+       default:
+               // For now, we'll roughly pick first one without
+               // considering dealing with any preferences such as
+               // DNS TTL, transport path quality, network routing
+               // information.
+               return al[0].toAddr()
+       }
+}
+
 var errNoSuitableAddress = errors.New("no suitable address found")
 
 // firstFavoriteAddr returns an address that implemets netaddr