diff --git a/cmd/neofs-cli/modules/root.go b/cmd/neofs-cli/modules/root.go index 269dbefda..a98efec90 100644 --- a/cmd/neofs-cli/modules/root.go +++ b/cmd/neofs-cli/modules/root.go @@ -235,12 +235,12 @@ func getSDKClient(key *ecdsa.PrivateKey) (client.Client, error) { return nil, err } - ipAddr, err := netAddr.IPAddrString() + hostAddr, err := netAddr.HostAddrString() if err != nil { return nil, errInvalidEndpoint } - c, err := client.New(client.WithAddress(ipAddr), client.WithDefaultPrivateKey(key)) + c, err := client.New(client.WithAddress(hostAddr), client.WithDefaultPrivateKey(key)) return c, err } diff --git a/cmd/neofs-node/container.go b/cmd/neofs-node/container.go index c28680ab4..fb0578a03 100644 --- a/cmd/neofs-node/container.go +++ b/cmd/neofs-node/container.go @@ -228,12 +228,12 @@ func (r *remoteLoadAnnounceProvider) InitRemote(srv loadroute.ServerInfo) (loadc return loadcontroller.SimpleWriterProvider(new(nopLoadWriter)), nil } - ipAddr, err := network.IPAddrFromMultiaddr(addr) + hostAddr, err := network.HostAddrFromMultiaddr(addr) if err != nil { return nil, errors.Wrap(err, "could not convert address to IP format") } - c, err := r.clientCache.Get(ipAddr) + c, err := r.clientCache.Get(hostAddr) if err != nil { return nil, errors.Wrap(err, "could not initialize API client") } diff --git a/cmd/neofs-node/object.go b/cmd/neofs-node/object.go index a4398accc..26c425d19 100644 --- a/cmd/neofs-node/object.go +++ b/cmd/neofs-node/object.go @@ -492,9 +492,9 @@ func (c *reputationClientConstructor) Get(addr string) (client.Client, error) { nm, err := netmap.GetLatestNetworkMap(c.nmSrc) if err == nil { for i := range nm.Nodes { - ipAddr, err := network.IPAddrFromMultiaddr(nm.Nodes[i].Address()) + hostAddr, err := network.HostAddrFromMultiaddr(nm.Nodes[i].Address()) if err == nil { - if ipAddr == addr { + if hostAddr == addr { prm := truststorage.UpdatePrm{} prm.SetPeer(reputation.PeerIDFromBytes(nm.Nodes[i].PublicKey())) diff --git a/cmd/neofs-node/reputation/common/remote.go b/cmd/neofs-node/reputation/common/remote.go index 66d3d7838..fd2c43ed2 100644 --- a/cmd/neofs-node/reputation/common/remote.go +++ b/cmd/neofs-node/reputation/common/remote.go @@ -76,12 +76,12 @@ func (rtp *remoteTrustProvider) InitRemote(srv reputationcommon.ServerInfo) (rep return trustcontroller.SimpleWriterProvider(new(NopReputationWriter)), nil } - ipAddr, err := network.IPAddrFromMultiaddr(addr) + hostAddr, err := network.HostAddrFromMultiaddr(addr) if err != nil { return nil, errors.Wrap(err, "could not convert address to IP format") } - c, err := rtp.clientCache.Get(ipAddr) + c, err := rtp.clientCache.Get(hostAddr) if err != nil { return nil, errors.Wrap(err, "could not initialize API client") } diff --git a/pkg/innerring/processors/audit/process.go b/pkg/innerring/processors/audit/process.go index 625b9e1fc..e4c3e9de0 100644 --- a/pkg/innerring/processors/audit/process.go +++ b/pkg/innerring/processors/audit/process.go @@ -117,7 +117,7 @@ func (ap *Processor) findStorageGroups(cid *container.ID, shuffled netmap.Nodes) zap.Int("total_tries", ln), ) - addr, err := network.IPAddrFromMultiaddr(shuffled[i].Address()) + addr, err := network.HostAddrFromMultiaddr(shuffled[i].Address()) if err != nil { log.Warn("can't parse remote address", zap.String("error", err.Error())) diff --git a/pkg/innerring/rpc.go b/pkg/innerring/rpc.go index 7e81f70ca..5f0b98370 100644 --- a/pkg/innerring/rpc.go +++ b/pkg/innerring/rpc.go @@ -74,7 +74,7 @@ func (c *ClientCache) getSG(ctx context.Context, addr *object.Address, nm *netma getParams.WithAddress(addr) for _, node := range placement.FlattenNodes(nodes) { - addr, err := network.IPAddrFromMultiaddr(node.Address()) + addr, err := network.HostAddrFromMultiaddr(node.Address()) if err != nil { c.log.Warn("can't parse remote address", zap.String("address", node.Address()), @@ -136,7 +136,7 @@ func (c *ClientCache) GetHeader(task *audit.Task, node *netmap.Node, id *object. headParams.WithMainFields() headParams.WithAddress(objAddress) - addr, err := network.IPAddrFromMultiaddr(node.Address()) + addr, err := network.HostAddrFromMultiaddr(node.Address()) if err != nil { return nil, fmt.Errorf("can't parse remote address %s: %w", node.Address(), err) } @@ -172,7 +172,7 @@ func (c *ClientCache) GetRangeHash(task *audit.Task, node *netmap.Node, id *obje rangeParams.WithRangeList(rng) rangeParams.WithSalt(nil) // it MUST be nil for correct hash concatenation in PDP game - addr, err := network.IPAddrFromMultiaddr(node.Address()) + addr, err := network.HostAddrFromMultiaddr(node.Address()) if err != nil { return nil, fmt.Errorf("can't parse remote address %s: %w", node.Address(), err) } diff --git a/pkg/network/address.go b/pkg/network/address.go index a62f71f4b..4c459357d 100644 --- a/pkg/network/address.go +++ b/pkg/network/address.go @@ -106,12 +106,12 @@ func IsLocalAddress(src LocalAddressSource, addr *Address) bool { return src.LocalAddress().ma.Equal(addr.ma) } -// IPAddrFromMultiaddr converts "/dns4/localhost/tcp/8080" to "192.168.0.1:8080". -func IPAddrFromMultiaddr(multiaddr string) (string, error) { +// HostAddrFromMultiaddr converts "/dns4/localhost/tcp/8080" to "localhost:8080". +func HostAddrFromMultiaddr(multiaddr string) (string, error) { address, err := AddressFromString(multiaddr) if err != nil { return "", err } - return address.IPAddrString() + return address.HostAddrString() } diff --git a/pkg/services/object/get/exec.go b/pkg/services/object/get/exec.go index 19fa646ba..4752e60b7 100644 --- a/pkg/services/object/get/exec.go +++ b/pkg/services/object/get/exec.go @@ -271,7 +271,7 @@ func (exec *execCtx) headChild(id *objectSDK.ID) (*object.Object, bool) { } func (exec execCtx) remoteClient(node *network.Address) (getClient, bool) { - ipAddr, err := node.IPAddrString() + hostAddr, err := node.HostAddrString() log := exec.log.With(zap.Stringer("node", node)) @@ -282,7 +282,7 @@ func (exec execCtx) remoteClient(node *network.Address) (getClient, bool) { log.Debug("could not calculate node IP address") case err == nil: - c, err := exec.svc.clientCache.get(ipAddr) + c, err := exec.svc.clientCache.get(hostAddr) switch { default: diff --git a/pkg/services/object/get/get_test.go b/pkg/services/object/get/get_test.go index f7d5fcd6c..046bd4708 100644 --- a/pkg/services/object/get/get_test.go +++ b/pkg/services/object/get/get_test.go @@ -411,7 +411,7 @@ func testNodeMatrix(t testing.TB, dim []int) ([]netmap.Nodes, [][]string) { na, err := network.AddressFromString(a) require.NoError(t, err) - as[j], err = na.IPAddrString() + as[j], err = na.HostAddrString() require.NoError(t, err) ni := netmap.NewNodeInfo() diff --git a/pkg/services/object/head/remote.go b/pkg/services/object/head/remote.go index 450d48c5f..c8b252a8a 100644 --- a/pkg/services/object/head/remote.go +++ b/pkg/services/object/head/remote.go @@ -65,7 +65,7 @@ func (h *RemoteHeader) Head(ctx context.Context, prm *RemoteHeadPrm) (*object.Ob return nil, errors.Wrapf(err, "(%T) could not receive private key", h) } - addr, err := prm.node.IPAddrString() + addr, err := prm.node.HostAddrString() if err != nil { return nil, err } diff --git a/pkg/services/object/put/remote.go b/pkg/services/object/put/remote.go index 3c2b15353..426c0f51c 100644 --- a/pkg/services/object/put/remote.go +++ b/pkg/services/object/put/remote.go @@ -54,7 +54,7 @@ func (t *remoteTarget) Close() (*transformer.AccessIdentifiers, error) { return nil, errors.Wrapf(err, "(%T) could not receive private key", t) } - addr, err := t.addr.IPAddrString() + addr, err := t.addr.HostAddrString() if err != nil { return nil, err } diff --git a/pkg/services/object/search/exec.go b/pkg/services/object/search/exec.go index 226d5139b..7a4e25a24 100644 --- a/pkg/services/object/search/exec.go +++ b/pkg/services/object/search/exec.go @@ -118,7 +118,7 @@ func (exec *execCtx) generateTraverser(cid *container.ID) (*placement.Traverser, } func (exec execCtx) remoteClient(node *network.Address) (searchClient, bool) { - ipAddr, err := node.IPAddrString() + hostAddr, err := node.HostAddrString() log := exec.log.With(zap.Stringer("node", node)) @@ -129,7 +129,7 @@ func (exec execCtx) remoteClient(node *network.Address) (searchClient, bool) { log.Debug("could not calculate node IP address") case err == nil: - c, err := exec.svc.clientConstructor.get(ipAddr) + c, err := exec.svc.clientConstructor.get(hostAddr) switch { default: diff --git a/pkg/services/object/search/search_test.go b/pkg/services/object/search/search_test.go index f803c2b4c..339a8d244 100644 --- a/pkg/services/object/search/search_test.go +++ b/pkg/services/object/search/search_test.go @@ -209,7 +209,7 @@ func testNodeMatrix(t testing.TB, dim []int) ([]netmap.Nodes, [][]string) { na, err := network.AddressFromString(a) require.NoError(t, err) - as[j], err = na.IPAddrString() + as[j], err = na.HostAddrString() require.NoError(t, err) ni := netmap.NewNodeInfo()