diff options
Diffstat (limited to 'src/pkg/net/ipsock.go')
-rw-r--r-- | src/pkg/net/ipsock.go | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/src/pkg/net/ipsock.go b/src/pkg/net/ipsock.go index 4e2a5622b..9234f5aff 100644 --- a/src/pkg/net/ipsock.go +++ b/src/pkg/net/ipsock.go @@ -6,14 +6,10 @@ package net -import ( - "os" -) - var supportsIPv6, supportsIPv4map = probeIPv6Stack() func firstFavoriteAddr(filter func(IP) IP, addrs []string) (addr IP) { - if filter == anyaddr { + if filter == nil { // We'll take any IP address, but since the dialing code // does not yet try multiple addresses, prefer to use // an IPv4 address if possible. This is especially relevant @@ -61,14 +57,14 @@ func ipv6only(x IP) IP { type InvalidAddrError string -func (e InvalidAddrError) String() string { return string(e) } +func (e InvalidAddrError) Error() string { return string(e) } func (e InvalidAddrError) Timeout() bool { return false } func (e InvalidAddrError) Temporary() bool { return false } // SplitHostPort splits a network address of the form // "host:port" or "[host]:port" into host and port. // The latter form must be used when host contains a colon. -func SplitHostPort(hostport string) (host, port string, err os.Error) { +func SplitHostPort(hostport string) (host, port string, err error) { // The port starts after the last colon. i := last(hostport, ':') if i < 0 { @@ -102,7 +98,7 @@ func JoinHostPort(host, port string) string { } // Convert "host:port" into IP address and port. -func hostPortToIP(net, hostport string) (ip IP, iport int, err os.Error) { +func hostPortToIP(net, hostport string) (ip IP, iport int, err error) { var ( addr IP p, i int @@ -117,7 +113,7 @@ func hostPortToIP(net, hostport string) (ip IP, iport int, err os.Error) { // Try as an IP address. addr = ParseIP(host) if addr == nil { - filter := anyaddr + var filter func(IP) IP if net != "" && net[len(net)-1] == '4' { filter = ipv4only } |