diff --git a/sockets.go b/sockets.go index 016b994..b8c1316 100644 --- a/sockets.go +++ b/sockets.go @@ -24,6 +24,7 @@ import ( "fmt" "github.com/conformal/btcjson" "github.com/conformal/btcwire" + "net" "net/http" "sync" ) @@ -441,7 +442,7 @@ func FrontendListenAndServe() error { // TODO(jrick): We need some sort of authentication before websocket // connections are allowed, and perhaps TLS on the server as well. http.Handle("/frontend", websocket.Handler(frontendReqsNotifications)) - return http.ListenAndServe(fmt.Sprintf(":%s", cfg.SvrPort), nil) + return http.ListenAndServe(net.JoinHostPort("", cfg.SvrPort), nil) } // BtcdConnect connects to a running btcd instance over a websocket @@ -450,7 +451,7 @@ func FrontendListenAndServe() error { func BtcdConnect(reply chan error) { // btcd requires basic authorization, so we use a custom config with // the Authorization header set. - server := fmt.Sprintf("ws://localhost:%s/wallet", cfg.BtcdPort) + server := fmt.Sprintf("ws://%s/wallet", net.JoinHostPort("localhost", cfg.BtcdPort)) login := cfg.Username + ":" + cfg.Password auth := "Basic " + base64.StdEncoding.EncodeToString([]byte(login)) config, err := websocket.NewConfig(server, "http://localhost/")