From 44b19c145f9524d6c3b0f0e38c4edacc8d311755 Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Tue, 1 Jun 2021 16:34:14 +0300 Subject: [PATCH] [#493] cmd/node: Use new config for control service configuration Signed-off-by: Alex Vanin --- cmd/neofs-node/config.go | 2 -- cmd/neofs-node/control.go | 14 +++----------- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/cmd/neofs-node/config.go b/cmd/neofs-node/config.go index b84e47b1ba..2f56f15de3 100644 --- a/cmd/neofs-node/config.go +++ b/cmd/neofs-node/config.go @@ -389,8 +389,6 @@ func defaultConfiguration(v *viper.Viper) { v.SetDefault(cfgReplicatorPutTimeout, 5*time.Second) v.SetDefault(cfgObjectPutPoolSize, 10) - - v.SetDefault(cfgCtrlSvcAuthorizedKeys, []string{}) } func (c *cfg) LocalAddress() *network.Address { diff --git a/cmd/neofs-node/control.go b/cmd/neofs-node/control.go index 1238f06dc9..92a778b99f 100644 --- a/cmd/neofs-node/control.go +++ b/cmd/neofs-node/control.go @@ -8,6 +8,7 @@ import ( "github.com/nspcc-dev/neofs-api-go/pkg/object" crypto "github.com/nspcc-dev/neofs-crypto" + controlconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/control" grpcconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/grpc" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/engine" "github.com/nspcc-dev/neofs-node/pkg/services/control" @@ -15,17 +16,8 @@ import ( "google.golang.org/grpc" ) -const ( - cfgCtrlSvcSection = "control" - - cfgCtrlSvcAuthorizedKeys = cfgCtrlSvcSection + ".authorized_keys" - - cfgCtrlSvcGRPCSection = cfgCtrlSvcSection + ".grpc" - cfgCtrlGRPCEndpoint = cfgCtrlSvcGRPCSection + ".endpoint" -) - func initControlService(c *cfg) { - strKeys := c.viper.GetStringSlice(cfgCtrlSvcAuthorizedKeys) + strKeys := controlconfig.AuthorizedKeysString(c.appCfg) keys := make([][]byte, 0, len(strKeys)+1) // +1 for node key keys = append(keys, crypto.MarshalPublicKey(&c.key.PublicKey)) @@ -59,7 +51,7 @@ func initControlService(c *cfg) { var ( err error lis net.Listener - endpoint = c.viper.GetString(cfgCtrlGRPCEndpoint) + endpoint = controlconfig.GRPC(c.appCfg).Endpoint() ) if endpoint == "" || endpoint == grpcconfig.Endpoint(c.appCfg) {