Use net.JoinHostPort so IPv6 can be handled properly later.
This commit is contained in:
parent
e4c96d01c1
commit
44c5d29c3b
1 changed files with 3 additions and 2 deletions
|
@ -24,6 +24,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/conformal/btcjson"
|
"github.com/conformal/btcjson"
|
||||||
"github.com/conformal/btcwire"
|
"github.com/conformal/btcwire"
|
||||||
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
|
@ -441,7 +442,7 @@ func FrontendListenAndServe() error {
|
||||||
// TODO(jrick): We need some sort of authentication before websocket
|
// TODO(jrick): We need some sort of authentication before websocket
|
||||||
// connections are allowed, and perhaps TLS on the server as well.
|
// connections are allowed, and perhaps TLS on the server as well.
|
||||||
http.Handle("/frontend", websocket.Handler(frontendReqsNotifications))
|
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
|
// BtcdConnect connects to a running btcd instance over a websocket
|
||||||
|
@ -450,7 +451,7 @@ func FrontendListenAndServe() error {
|
||||||
func BtcdConnect(reply chan error) {
|
func BtcdConnect(reply chan error) {
|
||||||
// btcd requires basic authorization, so we use a custom config with
|
// btcd requires basic authorization, so we use a custom config with
|
||||||
// the Authorization header set.
|
// 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
|
login := cfg.Username + ":" + cfg.Password
|
||||||
auth := "Basic " + base64.StdEncoding.EncodeToString([]byte(login))
|
auth := "Basic " + base64.StdEncoding.EncodeToString([]byte(login))
|
||||||
config, err := websocket.NewConfig(server, "http://localhost/")
|
config, err := websocket.NewConfig(server, "http://localhost/")
|
||||||
|
|
Loading…
Reference in a new issue