Skip to content

Commit

Permalink
Problem: default gRPC init configuration bound to 0.0.0.0 (#665) (fixes
Browse files Browse the repository at this point in the history
#586)

Solution: Add customAppConfig support that configures gRPC listening addresses
  • Loading branch information
damoncro authored Oct 25, 2021
1 parent 425cd6d commit 94d7567
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion cmd/chain-maind/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"time"

conf "github.com/cosmos/cosmos-sdk/client/config"
serverconfig "github.com/cosmos/cosmos-sdk/server/config"

"github.com/imdario/mergo"
"github.com/spf13/cast"
Expand Down Expand Up @@ -74,7 +75,9 @@ func NewRootCmd() (*cobra.Command, params.EncodingConfig) {
return err
}

return server.InterceptConfigsPreRunHandler(cmd, "", nil)
customAppTemplate, customAppConfig := initAppConfig()

return server.InterceptConfigsPreRunHandler(cmd, customAppTemplate, customAppConfig)
},
}

Expand All @@ -83,6 +86,28 @@ func NewRootCmd() (*cobra.Command, params.EncodingConfig) {
return rootCmd, encodingConfig
}

// initAppConfig helps to override default appConfig template and configs.
// return "", nil if no custom configuration is required for the application.
func initAppConfig() (string, interface{}) {
// The following code snippet is just for reference.

type CustomAppConfig struct {
serverconfig.Config
}

// Optionally allow the chain developer to overwrite the SDK's default
// server config.
srvCfg := serverconfig.DefaultConfig()
srvCfg.GRPC.Address = "127.0.0.1:9090"
srvCfg.GRPCWeb.Address = "127.0.0.1:9091"

customAppConfig := CustomAppConfig{
Config: *srvCfg,
}

return serverconfig.DefaultConfigTemplate, customAppConfig
}

func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig) {
// authclient.Codec = encodingConfig.Marshaler
cfg := sdk.GetConfig()
Expand Down

0 comments on commit 94d7567

Please sign in to comment.