runtime/internal: Remove IPAddressChooser.

I lack historical context, but IPAddressChooser has been causing
trouble by excluding non-public IPs from endpoints published.
If non-public IPs aren't published, then peers are unable
to find each other on the local network and are forced to talk
through a proxy.

Change-Id: I8c6669baedbbd0448379f502e7604d7d8fbdbf00
diff --git a/runtime/factories/generic/generic.go b/runtime/factories/generic/generic.go
index d9f1951..60e330e 100644
--- a/runtime/factories/generic/generic.go
+++ b/runtime/factories/generic/generic.go
@@ -48,9 +48,8 @@
 
 	lf := commonFlags.ListenFlags()
 	listenSpec := rpc.ListenSpec{
-		Addrs:          rpc.ListenAddrs(lf.Addrs),
-		AddressChooser: internal.IPAddressChooser{},
-		Proxy:          lf.Proxy,
+		Addrs: rpc.ListenAddrs(lf.Addrs),
+		Proxy: lf.Proxy,
 	}
 
 	ishutdown := func() {
diff --git a/runtime/internal/address_chooser.go b/runtime/internal/address_chooser.go
index 8ceae26..fd3b4d0 100644
--- a/runtime/internal/address_chooser.go
+++ b/runtime/internal/address_chooser.go
@@ -12,8 +12,7 @@
 )
 
 type addressChooser struct {
-	logger    logging.Logger
-	ipChooser IPAddressChooser
+	logger logging.Logger
 }
 
 func (c *addressChooser) ChooseAddresses(protocol string, candidates []net.Addr) ([]net.Addr, error) {
@@ -21,15 +20,12 @@
 		c.logger.Infof("CloudVM public IP address: %v", ipaddr)
 		return []net.Addr{ipaddr}, nil
 	}
-	return c.ipChooser.ChooseAddresses(protocol, candidates)
+	return candidates, nil
 }
 
-// NewAddressChooser will return the public IP of process if the process is
-// being hosted by a cloud service provider (e.g. Google Compute Engine,
-// Amazon EC2), and if not will be the same as IPAddressChooser.
+// NewAddressChooser prefers the public IP if a process is running on a cloud
+// service provider (such as Google Compute Engine or Amazon EC2), otherwise
+// it keeps all the addresses of all interfaces.
 func NewAddressChooser(logger logging.Logger) rpc.AddressChooser {
-	if HasPublicIP(logger) {
-		return IPAddressChooser{}
-	}
 	return &addressChooser{logger: logger}
 }
diff --git a/runtime/internal/util.go b/runtime/internal/util.go
index 7b5506a..a868af7 100644
--- a/runtime/internal/util.go
+++ b/runtime/internal/util.go
@@ -5,13 +5,8 @@
 package internal
 
 import (
-	"fmt"
-	"net"
 	"os"
-	"strings"
 
-	"v.io/v23/logging"
-	"v.io/x/lib/netstate"
 	"v.io/x/ref/internal/logger"
 	"v.io/x/ref/lib/exec"
 	"v.io/x/ref/lib/flags"
@@ -55,53 +50,3 @@
 	}
 	return nil
 }
-
-// IPAddressChooser returns the preferred IP address, which is,
-// a public IPv4 address, then any non-loopback IPv4, then a public
-// IPv6 address and finally any non-loopback/link-local IPv6
-type IPAddressChooser struct{}
-
-func (IPAddressChooser) ChooseAddresses(network string, addrs []net.Addr) ([]net.Addr, error) {
-	if !netstate.IsIPProtocol(network) {
-		return nil, fmt.Errorf("can't support network protocol %q", network)
-	}
-	accessible := netstate.ConvertToAddresses(addrs)
-
-	// Try and find an address on a interface with a default route.
-	// We give preference to IPv4 over IPv6 for compatibility for now.
-	var predicates []netstate.AddressPredicate
-	if !strings.HasSuffix(network, "6") {
-		predicates = append(predicates, netstate.IsPublicUnicastIPv4, netstate.IsUnicastIPv4)
-	}
-	if !strings.HasSuffix(network, "4") {
-		predicates = append(predicates, netstate.IsPublicUnicastIPv6, netstate.IsUnicastIPv6)
-	}
-
-	for _, predicate := range predicates {
-		if addrs := accessible.Filter(predicate); len(addrs) > 0 {
-			return addrs.AsNetAddrs(), nil
-		}
-	}
-	return []net.Addr{}, nil
-}
-
-// HasPublicIP returns true if the host has at least one public IP address.
-func HasPublicIP(log logging.Logger) bool {
-	state, err := netstate.GetAccessibleIPs()
-	if err != nil {
-		log.VI(0).Infof("failed to determine network state: %s", err)
-		return false
-	}
-	any := state.Filter(netstate.IsUnicastIP)
-	if len(any) == 0 {
-		log.VI(1).Infof("failed to find any usable IP addresses at startup")
-		return false
-	}
-	for _, a := range any {
-		if netstate.IsPublicUnicastIPv4(a) {
-			log.Infof("Found a public IP address: %v", a)
-			return true
-		}
-	}
-	return false
-}