forked from TrueCloudLab/frostfs-node
cd545f0160
In previous implementation NeoFS CLI app used `network.Address.HostAddr` as a server URI, which caused scheme loss since host address doesn't contain it. Rename `HostAddr` to `URIAddr` and make it to return URI address with `grpcs` scheme if TLS is enabled. Make `TLSEnabled` unexported since it was used to provide default `tls.Config` only (it is used by default in SDK). Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
30 lines
619 B
Go
30 lines
619 B
Go
package internal
|
|
|
|
import (
|
|
"crypto/ecdsa"
|
|
"fmt"
|
|
|
|
"github.com/nspcc-dev/neofs-node/pkg/network"
|
|
"github.com/nspcc-dev/neofs-sdk-go/client"
|
|
)
|
|
|
|
// GetSDKClient returns default neofs-sdk-go client.
|
|
func GetSDKClient(key *ecdsa.PrivateKey, addr network.Address) (*client.Client, error) {
|
|
var (
|
|
c client.Client
|
|
prmInit client.PrmInit
|
|
prmDial client.PrmDial
|
|
)
|
|
|
|
prmInit.SetDefaultPrivateKey(*key)
|
|
prmInit.ResolveNeoFSFailures()
|
|
prmDial.SetServerURI(addr.URIAddr())
|
|
|
|
c.Init(prmInit)
|
|
|
|
if err := c.Dial(prmDial); err != nil {
|
|
return nil, fmt.Errorf("can't init SDK client: %w", err)
|
|
}
|
|
|
|
return &c, nil
|
|
}
|