From 20692c22d7407125dba801dadee7413c6bc6b0a6 Mon Sep 17 00:00:00 2001 From: Mikio Hara Date: Fri, 30 Aug 2013 09:28:26 +0900 Subject: [PATCH] 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 --- src/pkg/net/ipsock.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/pkg/net/ipsock.go b/src/pkg/net/ipsock.go index 10a51f490d..20407872d7 100644 --- a/src/pkg/net/ipsock.go +++ b/src/pkg/net/ipsock.go @@ -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 -- 2.48.1