mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-19 21:31:37 +00:00
parent
16f41238b8
commit
37bd0198d9
3 changed files with 10 additions and 4 deletions
|
|
@ -20,6 +20,7 @@ import (
|
|||
"fmt"
|
||||
"io"
|
||||
"log/slog"
|
||||
"net"
|
||||
"net/http"
|
||||
_ "net/http/pprof"
|
||||
"os"
|
||||
|
|
@ -312,7 +313,11 @@ func Setup(ctx *cli.Context) error {
|
|||
|
||||
// pprof server
|
||||
if ctx.Bool(pprofFlag.Name) {
|
||||
address := fmt.Sprintf("%s:%d", ctx.String(pprofAddrFlag.Name), ctx.Int(pprofPortFlag.Name))
|
||||
listenHost := ctx.String(pprofAddrFlag.Name)
|
||||
|
||||
port := ctx.Int(pprofPortFlag.Name)
|
||||
|
||||
address := net.JoinHostPort(listenHost, fmt.Sprintf("%d", port))
|
||||
// This context value ("metrics-addr") represents the utils.MetricsHTTPFlag.Name.
|
||||
// It cannot be imported because it will cause a cyclical dependency.
|
||||
StartPProf(address, !ctx.IsSet("metrics-addr") && !ctx.IsSet("metrics.addr"))
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ package node
|
|||
import (
|
||||
"crypto/ecdsa"
|
||||
"fmt"
|
||||
"net"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
|
|
@ -246,7 +247,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.
|
||||
|
|
@ -265,7 +266,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.
|
||||
|
|
|
|||
|
|
@ -111,7 +111,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
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue