Skip to content

Commit a3ca1b2

Browse files
weiihannfjl
andauthored
cmd/utils: fix HTTPHost, WSHost flag priority (#28669)
Co-authored-by: Felix Lange <[email protected]>
1 parent e206d3f commit a3ca1b2

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

cmd/utils/flags.go

+8-4
Original file line numberDiff line numberDiff line change
@@ -1088,8 +1088,10 @@ func SplitAndTrim(input string) (ret []string) {
10881088
// setHTTP creates the HTTP RPC listener interface string from the set
10891089
// command line flags, returning empty if the HTTP endpoint is disabled.
10901090
func setHTTP(ctx *cli.Context, cfg *node.Config) {
1091-
if ctx.Bool(HTTPEnabledFlag.Name) && cfg.HTTPHost == "" {
1092-
cfg.HTTPHost = "127.0.0.1"
1091+
if ctx.Bool(HTTPEnabledFlag.Name) {
1092+
if cfg.HTTPHost == "" {
1093+
cfg.HTTPHost = "127.0.0.1"
1094+
}
10931095
if ctx.IsSet(HTTPListenAddrFlag.Name) {
10941096
cfg.HTTPHost = ctx.String(HTTPListenAddrFlag.Name)
10951097
}
@@ -1153,8 +1155,10 @@ func setGraphQL(ctx *cli.Context, cfg *node.Config) {
11531155
// setWS creates the WebSocket RPC listener interface string from the set
11541156
// command line flags, returning empty if the HTTP endpoint is disabled.
11551157
func setWS(ctx *cli.Context, cfg *node.Config) {
1156-
if ctx.Bool(WSEnabledFlag.Name) && cfg.WSHost == "" {
1157-
cfg.WSHost = "127.0.0.1"
1158+
if ctx.Bool(WSEnabledFlag.Name) {
1159+
if cfg.WSHost == "" {
1160+
cfg.WSHost = "127.0.0.1"
1161+
}
11581162
if ctx.IsSet(WSListenAddrFlag.Name) {
11591163
cfg.WSHost = ctx.String(WSListenAddrFlag.Name)
11601164
}

0 commit comments

Comments
 (0)