From cec7dcb02acb6c3ba58a6372eaa61fde0c5bf56c Mon Sep 17 00:00:00 2001 From: Daniel Liu Date: Mon, 4 Nov 2024 12:31:16 +0800 Subject: [PATCH] node: report actual port used for http rpc (#20789) --- node/node.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/node/node.go b/node/node.go index 709b1a3cfb..c5adec4451 100644 --- a/node/node.go +++ b/node/node.go @@ -357,7 +357,9 @@ func (n *Node) startHTTP(endpoint string, apis []rpc.API, modules []string, cors if err != nil { return err } - n.log.Info("HTTP endpoint opened", "url", fmt.Sprintf("http://%s", endpoint), "cors", strings.Join(cors, ","), "vhosts", strings.Join(vhosts, ",")) + n.log.Info("HTTP endpoint opened", "url", fmt.Sprintf("http://%v/", listener.Addr()), + "cors", strings.Join(cors, ","), + "vhosts", strings.Join(vhosts, ",")) // All listeners booted successfully n.httpEndpoint = endpoint n.httpListener = listener @@ -369,10 +371,10 @@ func (n *Node) startHTTP(endpoint string, apis []rpc.API, modules []string, cors // stopHTTP terminates the HTTP RPC endpoint. func (n *Node) stopHTTP() { if n.httpListener != nil { + url := fmt.Sprintf("http://%v/", n.httpListener.Addr()) n.httpListener.Close() n.httpListener = nil - - n.log.Info("HTTP endpoint closed", "url", fmt.Sprintf("http://%s", n.httpEndpoint)) + n.log.Info("HTTP endpoint closed", "url", url) } if n.httpHandler != nil { n.httpHandler.Stop()