1
0
mirror of https://github.com/golang/go synced 2024-11-17 12:44:49 -07:00

net: add addrList

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
This commit is contained in:
Mikio Hara 2013-08-30 09:28:26 +09:00
parent 9456adb36b
commit 20692c22d7

View 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