-
Notifications
You must be signed in to change notification settings - Fork 21.4k
Closed
Labels
Description
Rationale
As a user, I would assume that specifying flags would overwrite the config files. While this is true for most flags, the behavior is the opposite for http.addr and ws.addr. Here's an example:
config.toml
[Node]
HTTPHost = "127.0.0.1"
WSHost = "127.0.0.1"
Command:
./geth --datadir node --mainnet --http --http.addr 0.0.0.0 --ws --ws.addr 0.0.0.0
Expected output:
...
INFO [12-12|14:17:21.325] HTTP server started endpoint=[::]:8545 auth=false prefix= cors= vhosts=localhost
INFO [12-12|14:17:21.326] WebSocket enabled url=ws://[::]:8546
...Actual output:
...
INFO [12-12|14:16:47.073] HTTP server started endpoint=127.0.0.1:8545 auth=false prefix= cors= vhosts=localhost
INFO [12-12|14:16:47.073] WebSocket enabled url=ws://127.0.0.1:8546
...Implementation
Just remove the empty check for the address. For example:
// Before
func setHTTP(ctx *cli.Context, cfg *node.Config) {
if ctx.Bool(HTTPEnabledFlag.Name) && cfg.HTTPHost == "" {
cfg.HTTPHost = "127.0.0.1"
if ctx.IsSet(HTTPListenAddrFlag.Name) {
cfg.HTTPHost = ctx.String(HTTPListenAddrFlag.Name)
}
}
...
// After
func setHTTP(ctx *cli.Context, cfg *node.Config) {
if ctx.Bool(HTTPEnabledFlag.Name) {
cfg.HTTPHost = "127.0.0.1"
if ctx.IsSet(HTTPListenAddrFlag.Name) {
cfg.HTTPHost = ctx.String(HTTPListenAddrFlag.Name)
}
}