network

package
v0.36.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 26, 2023 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StringifyGroup added in v0.22.0

func StringifyGroup(x AddressGroup) string

StringifyGroup returns concatenation of all addresses from the AddressGroup.

The result is order-dependent.

func VerifyMultiAddress added in v0.22.0

func VerifyMultiAddress(ni netmap.NodeInfo) error

VerifyMultiAddress validates multiaddress of n.

If n's address contains more than 3 protocols or less than 2 protocols an error returns.

If n's address's protocol order is incorrect an error returns.

Correct composition(and order from low to high level) of protocols:

  1. dns4/ip4/ip6
  2. tcp
  3. tls(optional, may be absent)

func WriteToNodeInfo added in v0.22.0

func WriteToNodeInfo(g AddressGroup, ni *netmap.NodeInfo)

WriteToNodeInfo writes AddressGroup to netmap.NodeInfo structure.

Types

type Address

type Address struct {
	// contains filtered or unexported fields
}

Address represents the NeoFS node network address.

func (*Address) FromString added in v0.22.0

func (a *Address) FromString(s string) error

FromString restores Address from a string representation.

Supports URIAddr, MultiAddr and HostAddr strings.

func (Address) String added in v0.12.0

func (a Address) String() string

String returns multiaddr string.

func (Address) URIAddr added in v0.28.1

func (a Address) URIAddr() string

URIAddr returns Address as a URI.

Panics if host address cannot be fetched from Address.

See also FromString.

type AddressGroup added in v0.22.0

type AddressGroup []Address

AddressGroup represents list of network addresses of the node.

List is sorted by priority of use.

func (*AddressGroup) FromIterator added in v0.22.0

func (x *AddressGroup) FromIterator(iter MultiAddressIterator) error

FromIterator forms AddressGroup from MultiAddressIterator structure. The result is sorted with sort.Sort.

Returns an error in the absence of addresses or if any of the addresses are incorrect.

func (*AddressGroup) FromStringSlice added in v0.33.0

func (x *AddressGroup) FromStringSlice(addr []string) error

FromStringSlice forms AddressGroup from a string slice.

Returns an error in the absence of addresses or if any of the addresses are incorrect.

func (AddressGroup) Intersects added in v0.22.0

func (x AddressGroup) Intersects(x2 AddressGroup) bool

Intersects checks if two AddressGroup have at least one common address.

func (AddressGroup) IterateAddresses added in v0.22.0

func (x AddressGroup) IterateAddresses(f func(Address) bool)

IterateAddresses iterates over all network addresses of the node.

Breaks iterating on handler's true return.

Handler should not be nil.

func (AddressGroup) Len added in v0.22.0

func (x AddressGroup) Len() int

Len returns number of addresses in AddressGroup.

func (AddressGroup) Less added in v0.22.0

func (x AddressGroup) Less(i, j int) bool

Less returns true if i-th address in AddressGroup supports TLS and j-th one doesn't.

func (AddressGroup) Swap added in v0.22.0

func (x AddressGroup) Swap(i, j int)

Swap swaps i-th and j-th addresses in AddressGroup.

type MultiAddressIterator added in v0.22.0

type MultiAddressIterator interface {
	// Must iterate over network addresses and pass each one
	// to the handler until it returns true.
	IterateAddresses(func(string) bool)

	// Must return number of addresses in group.
	NumberOfAddresses() int
}

MultiAddressIterator is an interface of network address group.

type NodeEndpointsIterator added in v0.29.0

type NodeEndpointsIterator netmap.NodeInfo

NodeEndpointsIterator is a wrapper over netmap.NodeInfo which implements MultiAddressIterator.

func (NodeEndpointsIterator) IterateAddresses added in v0.29.0

func (x NodeEndpointsIterator) IterateAddresses(f func(string) bool)

func (NodeEndpointsIterator) NumberOfAddresses added in v0.29.0

func (x NodeEndpointsIterator) NumberOfAddresses() int

Directories

Path Synopsis
transport

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL