proxy: mount the ws endpoint as well if we are listening on tcp.
Change-Id: Iaaa7a1253f6e3a944b9fbcad9699caa459821683
diff --git a/lib/modules/core/proxy.go b/lib/modules/core/proxy.go
index 3f83ece..4cba574 100644
--- a/lib/modules/core/proxy.go
+++ b/lib/modules/core/proxy.go
@@ -3,6 +3,7 @@
import (
"fmt"
"io"
+ "strings"
"time"
"veyron.io/veyron/veyron2/naming"
@@ -48,6 +49,12 @@
defer pub.WaitForStop()
defer pub.Stop()
pub.AddServer(pname, false)
+ // If the protocol is tcp we need to also publish the websocket endpoint.
+ // TODO(bjornick): Remove this hack before we launch.
+ if strings.HasPrefix(proxy.Endpoint().Addr().Network(), "tcp") {
+ wsEP := strings.Replace(pname, "@"+proxy.Endpoint().Addr().Network()+"@", "@ws@", 1)
+ pub.AddServer(wsEP, false)
+ }
for _, name := range args {
pub.AddName(name)
}
diff --git a/services/proxy/proxyd/main.go b/services/proxy/proxyd/main.go
index be03702..b31b919 100644
--- a/services/proxy/proxyd/main.go
+++ b/services/proxy/proxyd/main.go
@@ -6,6 +6,7 @@
"flag"
"net/http"
_ "net/http/pprof"
+ "strings"
"time"
"veyron.io/veyron/veyron2/naming"
@@ -47,7 +48,15 @@
publisher := publisher.New(r.NewContext(), r.Namespace(), time.Minute)
defer publisher.WaitForStop()
defer publisher.Stop()
- publisher.AddServer(naming.JoinAddressName(proxy.Endpoint().String(), ""), false)
+ ep := naming.JoinAddressName(proxy.Endpoint().String(), "")
+ publisher.AddServer(ep, false)
+ // If the protocol is tcp we need to also publish the websocket endpoint.
+ // TODO(bjornick): Remove this hack before we launch.
+ if strings.HasPrefix(proxy.Endpoint().Addr().Network(), "tcp") {
+ wsEP := strings.Replace(ep, "@"+proxy.Endpoint().Addr().Network()+"@", "@ws@", 1)
+ publisher.AddServer(wsEP, false)
+ }
+
publisher.AddName(*name)
}