From a3ca1b28188f2f5747e05d23bfc4f0f7ce1007f0 Mon Sep 17 00:00:00 2001 From: Ng Wei Han <47109095+weiihann@users.noreply.github.com> Date: Tue, 12 Dec 2023 21:40:50 +0800 Subject: [PATCH] cmd/utils: fix HTTPHost, WSHost flag priority (#28669) Co-authored-by: Felix Lange --- cmd/utils/flags.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index d4c918bf4..159c47ca0 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -1088,8 +1088,10 @@ func SplitAndTrim(input string) (ret []string) { // setHTTP creates the HTTP RPC listener interface string from the set // command line flags, returning empty if the HTTP endpoint is disabled. func setHTTP(ctx *cli.Context, cfg *node.Config) { - if ctx.Bool(HTTPEnabledFlag.Name) && cfg.HTTPHost == "" { - cfg.HTTPHost = "127.0.0.1" + if ctx.Bool(HTTPEnabledFlag.Name) { + if cfg.HTTPHost == "" { + cfg.HTTPHost = "127.0.0.1" + } if ctx.IsSet(HTTPListenAddrFlag.Name) { cfg.HTTPHost = ctx.String(HTTPListenAddrFlag.Name) } @@ -1153,8 +1155,10 @@ func setGraphQL(ctx *cli.Context, cfg *node.Config) { // setWS creates the WebSocket RPC listener interface string from the set // command line flags, returning empty if the HTTP endpoint is disabled. func setWS(ctx *cli.Context, cfg *node.Config) { - if ctx.Bool(WSEnabledFlag.Name) && cfg.WSHost == "" { - cfg.WSHost = "127.0.0.1" + if ctx.Bool(WSEnabledFlag.Name) { + if cfg.WSHost == "" { + cfg.WSHost = "127.0.0.1" + } if ctx.IsSet(WSListenAddrFlag.Name) { cfg.WSHost = ctx.String(WSListenAddrFlag.Name) }