Skip to content

Commit 0734c4b

Browse files
authored
node, cmd/clef: report actual port used for http rpc (#20789)
1 parent a75c061 commit 0734c4b

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

‎cmd/clef/main.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -545,12 +545,12 @@ func signer(c *cli.Context) error {
545545
if err != nil {
546546
utils.Fatalf("Could not start RPC api: %v", err)
547547
}
548-
extapiURL = fmt.Sprintf("http://%s", httpEndpoint)
548+
extapiURL = fmt.Sprintf("http://%v/", listener.Addr())
549549
log.Info("HTTP endpoint opened", "url", extapiURL)
550550

551551
defer func() {
552552
listener.Close()
553-
log.Info("HTTP endpoint closed", "url", httpEndpoint)
553+
log.Info("HTTP endpoint closed", "url", extapiURL)
554554
}()
555555
}
556556
if !c.GlobalBool(utils.IPCDisabledFlag.Name) {

‎node/node.go‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,9 @@ func (n *Node) startHTTP(endpoint string, apis []rpc.API, modules []string, cors
368368
if err != nil {
369369
return err
370370
}
371-
n.log.Info("HTTP endpoint opened", "url", fmt.Sprintf("http://%s", endpoint), "cors", strings.Join(cors, ","), "vhosts", strings.Join(vhosts, ","))
371+
n.log.Info("HTTP endpoint opened", "url", fmt.Sprintf("http://%v/", listener.Addr()),
372+
"cors", strings.Join(cors, ","),
373+
"vhosts", strings.Join(vhosts, ","))
372374
// All listeners booted successfully
373375
n.httpEndpoint = endpoint
374376
n.httpListener = listener
@@ -380,10 +382,10 @@ func (n *Node) startHTTP(endpoint string, apis []rpc.API, modules []string, cors
380382
// stopHTTP terminates the HTTP RPC endpoint.
381383
func (n *Node) stopHTTP() {
382384
if n.httpListener != nil {
385+
url := fmt.Sprintf("http://%v/", n.httpListener.Addr())
383386
n.httpListener.Close()
384387
n.httpListener = nil
385-
386-
n.log.Info("HTTP endpoint closed", "url", fmt.Sprintf("http://%s", n.httpEndpoint))
388+
n.log.Info("HTTP endpoint closed", "url", url)
387389
}
388390
if n.httpHandler != nil {
389391
n.httpHandler.Stop()

0 commit comments

Comments
 (0)