Configure whether to dial secure connection to remote Nitro node

This commit is contained in:
neeraj 2023-10-18 10:08:26 +05:30 committed by Prathamesh Musale
parent b52f83c0d7
commit 71c028435d
4 changed files with 9 additions and 2 deletions

View File

@ -57,6 +57,7 @@ func addNitroFlags(command *cobra.Command) {
command.PersistentFlags().String("nitro-tls-key-filepath", "", "nitro tlsKeyFilepath") command.PersistentFlags().String("nitro-tls-key-filepath", "", "nitro tlsKeyFilepath")
command.PersistentFlags().String("nitro-endpoint", "", "nitro endpoint") command.PersistentFlags().String("nitro-endpoint", "", "nitro endpoint")
command.PersistentFlags().Bool("nitro-is-secure", false, "nitro isSecure")
// nitro flag bindings // nitro flag bindings
viper.BindPFlag("nitro.runNodeInProcess", command.PersistentFlags().Lookup("nitro-run-node-in-process")) viper.BindPFlag("nitro.runNodeInProcess", command.PersistentFlags().Lookup("nitro-run-node-in-process"))
@ -78,4 +79,5 @@ func addNitroFlags(command *cobra.Command) {
viper.BindPFlag("nitro.inProcesssNode.tlsKeyFilepath", command.PersistentFlags().Lookup("nitro-tls-key-filepath")) viper.BindPFlag("nitro.inProcesssNode.tlsKeyFilepath", command.PersistentFlags().Lookup("nitro-tls-key-filepath"))
viper.BindPFlag("nitro.remoteNode.nitroEndpoint", command.PersistentFlags().Lookup("nitro-endpoint")) viper.BindPFlag("nitro.remoteNode.nitroEndpoint", command.PersistentFlags().Lookup("nitro-endpoint"))
viper.BindPFlag("nitro.remoteNode.isSecure", command.PersistentFlags().Lookup("nitro-is-secure"))
} }

View File

@ -135,8 +135,7 @@ func serve() {
} else { } else {
log.Info("Connecting to a remote Nitro node") log.Info("Connecting to a remote Nitro node")
// TODO: Read from config file isSecure := nitroConfig.RemoteNode.IsSecure
isSecure := false
nitroRpcClient, err := nitroRpc.NewHttpRpcClient(nitroConfig.RemoteNode.NitroEndpoint, isSecure) nitroRpcClient, err := nitroRpc.NewHttpRpcClient(nitroConfig.RemoteNode.NitroEndpoint, isSecure)
if err != nil { if err != nil {
logWithCommand.Fatal(err) logWithCommand.Fatal(err)

View File

@ -54,3 +54,5 @@
[nitro.remoteNode] [nitro.remoteNode]
nitroEndpoint = "127.0.0.1:4005/api/v1" # NITRO_ENDPOINT nitroEndpoint = "127.0.0.1:4005/api/v1" # NITRO_ENDPOINT
isSecure = false

View File

@ -91,6 +91,7 @@ const (
NITRO_USE_DURABLE_STORE = "NITRO_USE_DURABLE_STORE" NITRO_USE_DURABLE_STORE = "NITRO_USE_DURABLE_STORE"
NITRO_DURABLE_STORE_FOLDER = "NITRO_DURABLE_STORE_FOLDER" NITRO_DURABLE_STORE_FOLDER = "NITRO_DURABLE_STORE_FOLDER"
NITRO_ENDPOINT = "NITRO_ENDPOINT" NITRO_ENDPOINT = "NITRO_ENDPOINT"
NITRO_IS_SECURE = "NITRO_IS_SECURE"
NITRO_MSG_PORT = "NITRO_MSG_PORT" NITRO_MSG_PORT = "NITRO_MSG_PORT"
NITRO_WS_MSG_PORT = "NITRO_WS_MSG_PORT" NITRO_WS_MSG_PORT = "NITRO_WS_MSG_PORT"
NITRO_RPC_PORT = "NITRO_RPC_PORT" NITRO_RPC_PORT = "NITRO_RPC_PORT"
@ -118,6 +119,7 @@ type InProcessNitroNodeConfig struct {
type RemoteNitroNodeConfig struct { type RemoteNitroNodeConfig struct {
NitroEndpoint string NitroEndpoint string
IsSecure bool
} }
type NitroConfig struct { type NitroConfig struct {
@ -352,6 +354,7 @@ func (c *Config) loadNitroConfig() {
viper.BindEnv("nitro.inProcesssNode.tlsKeyFilepath", NITRO_TLS_KEY_FILEPATH) viper.BindEnv("nitro.inProcesssNode.tlsKeyFilepath", NITRO_TLS_KEY_FILEPATH)
viper.BindEnv("nitro.remoteNode.nitroEndpoint", NITRO_ENDPOINT) viper.BindEnv("nitro.remoteNode.nitroEndpoint", NITRO_ENDPOINT)
viper.BindEnv("nitro.remoteNode.isSecure", NITRO_IS_SECURE)
c.Nitro.RunNodeInProcess = viper.GetBool("nitro.runNodeInProcess") c.Nitro.RunNodeInProcess = viper.GetBool("nitro.runNodeInProcess")
c.Nitro.RpcQueryRatesFile = viper.GetString("nitro.rpcQueryRatesFile") c.Nitro.RpcQueryRatesFile = viper.GetString("nitro.rpcQueryRatesFile")
@ -372,6 +375,7 @@ func (c *Config) loadNitroConfig() {
c.Nitro.InProcessNode.TlsKeyFilepath = viper.GetString("nitro.inProcesssNode.tlsKeyFilepath") c.Nitro.InProcessNode.TlsKeyFilepath = viper.GetString("nitro.inProcesssNode.tlsKeyFilepath")
c.Nitro.RemoteNode.NitroEndpoint = viper.GetString("nitro.remoteNode.nitroEndpoint") c.Nitro.RemoteNode.NitroEndpoint = viper.GetString("nitro.remoteNode.nitroEndpoint")
c.Nitro.RemoteNode.IsSecure = viper.GetBool("nitro.remoteNode.isSecure")
} }
func (c *Config) loadGroupCacheConfig() { func (c *Config) loadGroupCacheConfig() {