cmd/utils: allow HTTPHost and WSHost flags precede

This commit is contained in:
weiihann 2023-12-12 14:29:31 +08:00
parent e206d3f897
commit 1a1fb9174d

View file

@ -1088,7 +1088,7 @@ func SplitAndTrim(input string) (ret []string) {
// setHTTP creates the HTTP RPC listener interface string from the set // setHTTP creates the HTTP RPC listener interface string from the set
// command line flags, returning empty if the HTTP endpoint is disabled. // command line flags, returning empty if the HTTP endpoint is disabled.
func setHTTP(ctx *cli.Context, cfg *node.Config) { func setHTTP(ctx *cli.Context, cfg *node.Config) {
if ctx.Bool(HTTPEnabledFlag.Name) && cfg.HTTPHost == "" { if ctx.Bool(HTTPEnabledFlag.Name) {
cfg.HTTPHost = "127.0.0.1" cfg.HTTPHost = "127.0.0.1"
if ctx.IsSet(HTTPListenAddrFlag.Name) { if ctx.IsSet(HTTPListenAddrFlag.Name) {
cfg.HTTPHost = ctx.String(HTTPListenAddrFlag.Name) cfg.HTTPHost = ctx.String(HTTPListenAddrFlag.Name)
@ -1153,7 +1153,7 @@ func setGraphQL(ctx *cli.Context, cfg *node.Config) {
// setWS creates the WebSocket RPC listener interface string from the set // setWS creates the WebSocket RPC listener interface string from the set
// command line flags, returning empty if the HTTP endpoint is disabled. // command line flags, returning empty if the HTTP endpoint is disabled.
func setWS(ctx *cli.Context, cfg *node.Config) { func setWS(ctx *cli.Context, cfg *node.Config) {
if ctx.Bool(WSEnabledFlag.Name) && cfg.WSHost == "" { if ctx.Bool(WSEnabledFlag.Name) {
cfg.WSHost = "127.0.0.1" cfg.WSHost = "127.0.0.1"
if ctx.IsSet(WSListenAddrFlag.Name) { if ctx.IsSet(WSListenAddrFlag.Name) {
cfg.WSHost = ctx.String(WSListenAddrFlag.Name) cfg.WSHost = ctx.String(WSListenAddrFlag.Name)