Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(dot/rpc): include unsafe flags to be considered by RPC layer #2483

Merged
merged 9 commits into from
Apr 18, 2022
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 @@ -115,14 +115,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