Skip to content

Commit

Permalink
fix(dot/rpc): include unsafe flags to be considered by RPC layer (#2483)
Browse files Browse the repository at this point in the history
* fix: include unsafe flags to be considered by RPC layer
  • Loading branch information
EclesioMeloJunior committed Apr 18, 2022
1 parent 7a84636 commit 3822257
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 10 deletions.
22 changes: 22 additions & 0 deletions cmd/gossamer/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,28 @@ func setDotRPCConfig(ctx *cli.Context, tomlCfg ctoml.RPCConfig, cfg *dot.RPCConf
cfg.External = false
}

// check --rpc-unsafe flag value
if rpcUnsafe := ctx.GlobalBool(RPCUnsafeEnabledFlag.Name); rpcUnsafe {
cfg.Unsafe = true
}

// check --rpc-unsafe-external flag value
if externalUnsafe := ctx.GlobalBool(RPCUnsafeExternalFlag.Name); externalUnsafe {
cfg.Unsafe = true
cfg.UnsafeExternal = true
}

// check --ws-unsafe flag value
if wsUnsafe := ctx.GlobalBool(WSUnsafeEnabledFlag.Name); wsUnsafe {
cfg.WSUnsafe = true
}

// check --ws-unsafe-external flag value
if wsExternalUnsafe := ctx.GlobalBool(WSUnsafeExternalFlag.Name); wsExternalUnsafe {
cfg.WSUnsafe = true
cfg.WSUnsafeExternal = true
}

// check --rpcport flag and update node configuration
if port := ctx.GlobalUint(RPCPortFlag.Name); port != 0 {
cfg.Port = uint32(port)
Expand Down
20 changes: 12 additions & 8 deletions cmd/gossamer/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,18 @@ func dotConfigToToml(dcfg *dot.Config) *ctoml.Config {
}

cfg.RPC = ctoml.RPCConfig{
Enabled: dcfg.RPC.Enabled,
External: dcfg.RPC.External,
Port: dcfg.RPC.Port,
Host: dcfg.RPC.Host,
Modules: dcfg.RPC.Modules,
WSPort: dcfg.RPC.WSPort,
WS: dcfg.RPC.WS,
WSExternal: dcfg.RPC.WSExternal,
Enabled: dcfg.RPC.Enabled,
External: dcfg.RPC.External,
Unsafe: dcfg.RPC.Unsafe,
UnsafeExternal: dcfg.RPC.UnsafeExternal,
Port: dcfg.RPC.Port,
Host: dcfg.RPC.Host,
Modules: dcfg.RPC.Modules,
WSPort: dcfg.RPC.WSPort,
WS: dcfg.RPC.WS,
WSExternal: dcfg.RPC.WSExternal,
WSUnsafe: dcfg.RPC.WSUnsafe,
WSUnsafeExternal: dcfg.RPC.WSUnsafeExternal,
}

return cfg
Expand Down
4 changes: 2 additions & 2 deletions cmd/gossamer/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ var (
Usage: "Enable external websocket connections",
}
// WSFlag Enable the websockets server
WSUnsafeFlag = cli.BoolFlag{
WSUnsafeEnabledFlag = cli.BoolFlag{
Name: "ws-unsafe",
Usage: "Enable access to websocket unsafe calls",
}
Expand Down Expand Up @@ -436,7 +436,7 @@ var (
RPCModulesFlag,
WSFlag,
WSExternalFlag,
WSUnsafeFlag,
WSUnsafeEnabledFlag,
WSUnsafeExternalFlag,
WSPortFlag,

Expand Down

0 comments on commit 3822257

Please sign in to comment.