diff --git a/pkg/services/object/get/v2/get_forwarder.go b/pkg/services/object/get/v2/get_forwarder.go index 7314cceb..330a0642 100644 --- a/pkg/services/object/get/v2/get_forwarder.go +++ b/pkg/services/object/get/v2/get_forwarder.go @@ -2,6 +2,7 @@ package getsvc import ( "context" + "crypto/ecdsa" "errors" "fmt" "io" @@ -16,7 +17,6 @@ import ( "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/network" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/object/internal" internalclient "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/object/internal/client" - "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/object/util" "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object" ) @@ -24,16 +24,13 @@ type getRequestForwarder struct { OnceResign *sync.Once OnceHeaderSending *sync.Once GlobalProgress int - KeyStorage *util.KeyStorage + Key *ecdsa.PrivateKey Request *objectV2.GetRequest Stream *streamObjectWriter } func (f *getRequestForwarder) forwardRequestToNode(ctx context.Context, addr network.Address, c client.MultiAddressClient, pubkey []byte) (*object.Object, error) { - key, err := f.KeyStorage.GetKey(nil) - if err != nil { - return nil, err - } + var err error // once compose and resign forwarding request f.OnceResign.Do(func() { @@ -44,7 +41,7 @@ func (f *getRequestForwarder) forwardRequestToNode(ctx context.Context, addr net metaHdr.SetOrigin(f.Request.GetMetaHeader()) writeCurrentVersion(metaHdr) f.Request.SetMetaHeader(metaHdr) - err = signature.SignServiceMessage(key, f.Request) + err = signature.SignServiceMessage(f.Key, f.Request) }) if err != nil { diff --git a/pkg/services/object/get/v2/get_range_forwarder.go b/pkg/services/object/get/v2/get_range_forwarder.go index 8fa4351d..5893f8de 100644 --- a/pkg/services/object/get/v2/get_range_forwarder.go +++ b/pkg/services/object/get/v2/get_range_forwarder.go @@ -2,6 +2,7 @@ package getsvc import ( "context" + "crypto/ecdsa" "errors" "fmt" "io" @@ -16,23 +17,19 @@ import ( "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/network" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/object/internal" internalclient "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/object/internal/client" - "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/object/util" "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object" ) type getRangeRequestForwarder struct { OnceResign *sync.Once GlobalProgress int - KeyStorage *util.KeyStorage + Key *ecdsa.PrivateKey Request *objectV2.GetRangeRequest Stream *streamObjectRangeWriter } func (f *getRangeRequestForwarder) forwardRequestToNode(ctx context.Context, addr network.Address, c client.MultiAddressClient, pubkey []byte) (*object.Object, error) { - key, err := f.KeyStorage.GetKey(nil) - if err != nil { - return nil, err - } + var err error // once compose and resign forwarding request f.OnceResign.Do(func() { @@ -45,7 +42,7 @@ func (f *getRangeRequestForwarder) forwardRequestToNode(ctx context.Context, add f.Request.SetMetaHeader(metaHdr) - err = signature.SignServiceMessage(key, f.Request) + err = signature.SignServiceMessage(f.Key, f.Request) }) if err != nil { diff --git a/pkg/services/object/get/v2/head_forwarder.go b/pkg/services/object/get/v2/head_forwarder.go index e0b58a35..45c0174f 100644 --- a/pkg/services/object/get/v2/head_forwarder.go +++ b/pkg/services/object/get/v2/head_forwarder.go @@ -2,6 +2,7 @@ package getsvc import ( "context" + "crypto/ecdsa" "errors" "fmt" "sync" @@ -15,7 +16,6 @@ import ( "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/client" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/network" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/object/internal" - "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/object/util" frostfscrypto "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/crypto" "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object" oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id" @@ -26,17 +26,12 @@ type headRequestForwarder struct { Response *objectV2.HeadResponse OnceResign *sync.Once ObjectAddr oid.Address - KeyStorage *util.KeyStorage + Key *ecdsa.PrivateKey } func (f *headRequestForwarder) forwardRequestToNode(ctx context.Context, addr network.Address, c client.MultiAddressClient, pubkey []byte) (*object.Object, error) { var err error - key, err := f.KeyStorage.GetKey(nil) - if err != nil { - return nil, err - } - // once compose and resign forwarding request f.OnceResign.Do(func() { // compose meta header of the local server @@ -48,7 +43,7 @@ func (f *headRequestForwarder) forwardRequestToNode(ctx context.Context, addr ne f.Request.SetMetaHeader(metaHdr) - err = signature.SignServiceMessage(key, f.Request) + err = signature.SignServiceMessage(f.Key, f.Request) }) if err != nil { diff --git a/pkg/services/object/get/v2/util.go b/pkg/services/object/get/v2/util.go index 75228e2b..3a50a6ca 100644 --- a/pkg/services/object/get/v2/util.go +++ b/pkg/services/object/get/v2/util.go @@ -56,11 +56,16 @@ func (s *Service) toPrm(req *objectV2.GetRequest, stream objectSvc.GetObjectStre p.SetObjectWriter(streamWrapper) if !commonPrm.LocalOnly() { + key, err := s.keyStorage.GetKey(nil) + if err != nil { + return nil, err + } + forwarder := &getRequestForwarder{ OnceResign: &sync.Once{}, OnceHeaderSending: &sync.Once{}, GlobalProgress: 0, - KeyStorage: s.keyStorage, + Key: key, Request: req, Stream: streamWrapper, } @@ -107,10 +112,15 @@ func (s *Service) toRangePrm(req *objectV2.GetRangeRequest, stream objectSvc.Get } if !commonPrm.LocalOnly() { + key, err := s.keyStorage.GetKey(nil) + if err != nil { + return nil, err + } + forwarder := &getRangeRequestForwarder{ OnceResign: &sync.Once{}, GlobalProgress: 0, - KeyStorage: s.keyStorage, + Key: key, Request: req, Stream: streamWrapper, } @@ -239,12 +249,17 @@ func (s *Service) toHeadPrm(ctx context.Context, req *objectV2.HeadRequest, resp return p, nil } + key, err := s.keyStorage.GetKey(nil) + if err != nil { + return nil, err + } + forwarder := &headRequestForwarder{ Request: req, Response: resp, OnceResign: &sync.Once{}, ObjectAddr: objAddr, - KeyStorage: s.keyStorage, + Key: key, } p.SetRequestForwarder(groupAddressRequestForwarder(forwarder.forwardRequestToNode))