forked from TrueCloudLab/frostfs-node
[#1454] Upgrade NeoFS SDK Go module with new IDs
Core changes: * avoid package-colliding variable naming * avoid using pointers to IDs where unnecessary * avoid using `idSDK` import alias pattern * use `EncodeToString` for protocol string calculation and `String` for printing Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
cc6209e8a0
commit
1c30414a6c
218 changed files with 2095 additions and 2521 deletions
|
@ -1,14 +1,11 @@
|
|||
package control
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
rawclient "github.com/nspcc-dev/neofs-api-go/v2/rpc/client"
|
||||
"github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/common"
|
||||
"github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/commonflags"
|
||||
"github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/key"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/services/control"
|
||||
addressSDK "github.com/nspcc-dev/neofs-sdk-go/object/address"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
|
@ -22,20 +19,10 @@ var dropObjectsCmd = &cobra.Command{
|
|||
pk := key.Get(cmd)
|
||||
|
||||
dropObjectsList, _ := cmd.Flags().GetStringSlice(dropObjectsFlag)
|
||||
binAddrList := make([][]byte, 0, len(dropObjectsList))
|
||||
binAddrList := make([][]byte, len(dropObjectsList))
|
||||
|
||||
for i := range dropObjectsList {
|
||||
a := addressSDK.NewAddress()
|
||||
|
||||
err := a.Parse(dropObjectsList[i])
|
||||
if err != nil {
|
||||
common.ExitOnErr(cmd, "", fmt.Errorf("could not parse address #%d: %w", i, err))
|
||||
}
|
||||
|
||||
binAddr, err := a.Marshal()
|
||||
common.ExitOnErr(cmd, "could not marshal the address: %w", err)
|
||||
|
||||
binAddrList = append(binAddrList, binAddr)
|
||||
binAddrList[i] = []byte(dropObjectsList[i])
|
||||
}
|
||||
|
||||
body := new(control.DropObjectsRequest_Body)
|
||||
|
|
|
@ -24,16 +24,13 @@ func verifyResponse(cmd *cobra.Command,
|
|||
GetSign() []byte
|
||||
},
|
||||
body interface {
|
||||
StableMarshal([]byte) ([]byte, error)
|
||||
StableMarshal([]byte) []byte
|
||||
},
|
||||
) {
|
||||
if sigControl == nil {
|
||||
common.ExitOnErr(cmd, "", errors.New("missing response signature"))
|
||||
}
|
||||
|
||||
bodyData, err := body.StableMarshal(nil)
|
||||
common.ExitOnErr(cmd, "marshal response body: %w", err)
|
||||
|
||||
// TODO(@cthulhu-rider): #1387 use Signature message from NeoFS API to avoid conversion
|
||||
var sigV2 refs.Signature
|
||||
sigV2.SetScheme(refs.ECDSA_SHA512)
|
||||
|
@ -43,7 +40,7 @@ func verifyResponse(cmd *cobra.Command,
|
|||
var sig neofscrypto.Signature
|
||||
sig.ReadFromV2(sigV2)
|
||||
|
||||
if !sig.Verify(bodyData) {
|
||||
if !sig.Verify(body.StableMarshal(nil)) {
|
||||
common.ExitOnErr(cmd, "", errors.New("invalid response signature"))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue