discovery: advertise proxies' endpoints as well.

  Make AdvertiseServer to advertise proxies' endpoints as well.

Change-Id: I2e7dfe8bb5174c277ddc3cdd171fc76718cf1ece
diff --git a/lib/discovery/util/advertise.go b/lib/discovery/util/advertise.go
index feb9974..5835552 100644
--- a/lib/discovery/util/advertise.go
+++ b/lib/discovery/util/advertise.go
@@ -30,7 +30,7 @@
 	watcher := make(chan rpc.NetworkChange, 3)
 	server.WatchNetwork(watcher)
 
-	stop, err := advertise(ctx, service, server.Status().Endpoints, suffix, visibility)
+	stop, err := advertise(ctx, service, getEndpoints(server), suffix, visibility)
 	if err != nil {
 		server.UnwatchNetwork(watcher)
 		close(watcher)
@@ -45,7 +45,7 @@
 				if stop != nil {
 					stop() // Stop the previous advertisement.
 				}
-				stop, err = advertise(ctx, service, server.Status().Endpoints, suffix, visibility)
+				stop, err = advertise(ctx, service, getEndpoints(server), suffix, visibility)
 				if err != nil {
 					ctx.Error(err)
 				}
@@ -79,3 +79,13 @@
 	}
 	return stop, nil
 }
+
+// TODO(suharshs): Use server.Status().Endpoints only when migrating to a new server.
+func getEndpoints(server rpc.Server) []naming.Endpoint {
+	status := server.Status()
+	eps := status.Endpoints
+	for _, p := range status.Proxies {
+		eps = append(eps, p.Endpoint)
+	}
+	return eps
+}