netstate: Do not default to filtering away addresses.

I'm not sure of the history behind this, but filtering out all but the
IPv4 loopback address seems to be the wrong thing to do. Overall,
the philosophy is to "find all paths".

In practice, this behavior was hurting our Android app demos,
where a device not on a public network was ending up with
only 127.0.0.1 in rpc.Server.Status().Endpoints, which in turn
meant that even though peers on the same network (or within Bluetooth
range) could see an advertisement for this service, they couldn't
connect to it over the single localhost advertised endpoint.

Change-Id: I3efca02dd9be78c57129f71e567ad7d554843663
diff --git a/netstate/.api b/netstate/.api
index 7ea283d..adfcc04 100644
--- a/netstate/.api
+++ b/netstate/.api
@@ -74,4 +74,3 @@
 pkg netstate, var ErrNotAnIPProtocol error
 pkg netstate, var ErrUnspecifiedIPAddr error
 pkg netstate, var ErrUnsupportedProtocol error
-pkg netstate, var LoopbackIPv4AddressChooser AddressChooserFunc
diff --git a/netstate/chooser.go b/netstate/chooser.go
index 391a907..c8f687c 100644
--- a/netstate/chooser.go
+++ b/netstate/chooser.go
@@ -10,9 +10,6 @@
 )
 
 var (
-	LoopbackIPv4AddressChooser = AddressChooserFunc(func(protocol string, candidates []net.Addr) ([]net.Addr, error) {
-		return ConvertToAddresses(candidates).Filter(IsLoopbackIP).Filter(IsUnicastIPv4).AsNetAddrs(), nil
-	})
 	ErrNotAnIPProtocol = errors.New("requested protocol is not from the IP family")
 )
 
@@ -36,12 +33,12 @@
 // unspecified or not. An unspecified host can be used over any network interface
 // on the host. If the supplied address contains a port in then all of the
 // returned addresses will also contain that port.
+//
 // The returned net.Addr's need have the exact same protocol as that passed
 // in as a parameter, rather, the chooser should return net.Addr's that can
 // be used for that protocol. Using tcp as a parameter for example will generally
 // result in net.Addr's whose Network method returns "ip" or "ip6".
-// If a nil chooser is supplied then it is assumed then LoopbackIPv4AddressChooser
-// will be used.
+//
 // If the chooser fails to find any appropriate addresses then the protocol, addr
 // parameters will be returned as net.Addr (and if possible as a netstate.Address).
 //
@@ -78,12 +75,11 @@
 		}
 		return []net.Addr{WithIPHostAndPort(ipaddr, port)}, unspecified, nil
 	}
-	if chooser == nil {
-		chooser = LoopbackIPv4AddressChooser
-	}
-	chosen, err := chooser.ChooseAddresses(protocol, candidates)
-	if err != nil {
-		return nil, unspecified, err
+	chosen := candidates
+	if chooser != nil {
+		if chosen, err = chooser.ChooseAddresses(protocol, candidates); err != nil {
+			return nil, unspecified, err
+		}
 	}
 	if len(chosen) == 0 {
 		netaddr := NewNetAddr(protocol, addr)
diff --git a/netstate/chooser_test.go b/netstate/chooser_test.go
index 5213aab..ad8f5d2 100644
--- a/netstate/chooser_test.go
+++ b/netstate/chooser_test.go
@@ -175,7 +175,8 @@
 		t.Fatal(err)
 	}
 
-	if got, want := len(addrs), 1; got != want {
+	if got, want := len(addrs), 7; got != want {
+		// mockInterfacesAndRouteTable sets up with 7 IP addresses.
 		t.Fatalf("got %v, want %v", got, want)
 	}
 	if got, want := unspecified, true; got != want {