node: fix listening on IPv6 address (#27628) (#27635)

This commit is contained in:
Curith
2023-07-02 13:21:16 +02:00
committed by GitHub
parent 8bbb16b70e
commit 6ca3ef9a7b
5 changed files with 10 additions and 6 deletions
+3 -2
View File
@@ -19,6 +19,7 @@ package node
import (
"crypto/ecdsa"
"fmt"
"net"
"os"
"path/filepath"
"runtime"
@@ -263,7 +264,7 @@ func (c *Config) HTTPEndpoint() string {
if c.HTTPHost == "" {
return ""
}
return fmt.Sprintf("%s:%d", c.HTTPHost, c.HTTPPort)
return net.JoinHostPort(c.HTTPHost, fmt.Sprintf("%d", c.HTTPPort))
}
// DefaultHTTPEndpoint returns the HTTP endpoint used by default.
@@ -278,7 +279,7 @@ func (c *Config) WSEndpoint() string {
if c.WSHost == "" {
return ""
}
return fmt.Sprintf("%s:%d", c.WSHost, c.WSPort)
return net.JoinHostPort(c.WSHost, fmt.Sprintf("%d", c.WSPort))
}
// DefaultWSEndpoint returns the websocket endpoint used by default.
+1 -1
View File
@@ -112,7 +112,7 @@ func (h *httpServer) setListenAddr(host string, port int) error {
}
h.host, h.port = host, port
h.endpoint = fmt.Sprintf("%s:%d", host, port)
h.endpoint = net.JoinHostPort(host, fmt.Sprintf("%d", port))
return nil
}