diff --git a/pkg/network/address.go b/pkg/network/address.go index 5cc4e71c10..465a26aba1 100644 --- a/pkg/network/address.go +++ b/pkg/network/address.go @@ -6,7 +6,22 @@ import ( // Address represents the NeoFS node // network address. -// -// It is a type alias of -// github.com/multiformats/go-multiaddr.Multiaddr. -type Address = multiaddr.Multiaddr +type Address struct { + ma multiaddr.Multiaddr +} + +func (a Address) String() string { + return a.ma.String() +} + +// AddressFromString restores address from a string representation. +func AddressFromString(s string) (*Address, error) { + ma, err := multiaddr.NewMultiaddr(s) + if err != nil { + return nil, err + } + + return &Address{ + ma: ma, + }, nil +} diff --git a/pkg/network/listen.go b/pkg/network/listen.go index 14cd112240..0834ac5865 100644 --- a/pkg/network/listen.go +++ b/pkg/network/listen.go @@ -3,11 +3,12 @@ package network import ( "net" + "github.com/multiformats/go-multiaddr" manet "github.com/multiformats/go-multiaddr-net" ) // Listen announces on the local network address. -func Listen(addr Address) (net.Listener, error) { +func Listen(addr multiaddr.Multiaddr) (net.Listener, error) { mLis, err := manet.Listen(addr) if err != nil { return nil, err