addrutil

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SupportedTransportProtocols = [][]ma.Protocol{}

SupportedTransportProtocols is the list of supported transports for the swarm. These are []ma.Protocol lists. Populated at runtime from SupportedTransportStrings

View Source
var SupportedTransportStrings = []string{
	"/ip4/tcp",
	"/ip6/tcp",
	"/ip4/udp/utp",
	"/ip6/udp/utp",
	"/ip4/tcp/ws",
	"/ip6/tcp/ws",
}

SupportedTransportStrings is the list of supported transports for the swarm. These are strings of encapsulated multiaddr protocols. E.g.:

/ip4/tcp

Functions

func AddTransport

func AddTransport(s string) error

AddTransport adds a transport protocol combination to the list of supported transports

func AddrInList

func AddrInList(addr ma.Multiaddr, list []ma.Multiaddr) bool

AddrInList returns whether or not an address is part of a list. this is useful to check if NAT is happening (or other bugs?)

func AddrIsShareableOnWAN

func AddrIsShareableOnWAN(addr ma.Multiaddr) bool

AddrIsShareableOnWAN returns whether the given address should be shareable on the wide area network (wide internet).

func AddrOverNonLocalIP

func AddrOverNonLocalIP(a ma.Multiaddr) bool

AddrOverNonLocalIP returns whether the addr uses a non-local ip link

func AddrUsable

func AddrUsable(a ma.Multiaddr, partial bool) bool

AddrUsable returns whether our network can use this addr. We only use the transports in SupportedTransportStrings, and we do not link local addresses. Loopback is ok as we need to be able to connect to multiple ipfs nodes in the same machine.

func AddrUsableFunc

func AddrUsableFunc(m ma.Multiaddr) bool

func CheckNATWarning

func CheckNATWarning(observed, expected ma.Multiaddr, listen []ma.Multiaddr)

CheckNATWarning checks if our observed addresses differ. if so, informs the user that certain things might not work yet

func FilterAddrs

func FilterAddrs(a []ma.Multiaddr, filters ...func(ma.Multiaddr) bool) []ma.Multiaddr

FilterAddrs is a filter that removes certain addresses, according the given filters. if all filters return true, the address is kept.

func FilterNeg

func FilterNeg(f func(ma.Multiaddr) bool) func(ma.Multiaddr) bool

FilterNeg returns a negated version of the passed in filter

func FilterUsableAddrs

func FilterUsableAddrs(a []ma.Multiaddr) []ma.Multiaddr

FilterUsableAddrs removes certain addresses from a list. the addresses removed are those known NOT to work with our network. Namely, addresses with UTP.

func InterfaceAddresses

func InterfaceAddresses() ([]ma.Multiaddr, error)

InterfaceAddresses returns a list of addresses associated with local machine Note: we do not return link local addresses. IP loopback is ok, because we may be connecting to other nodes in the same machine.

func IsFDCostlyTransport

func IsFDCostlyTransport(a ma.Multiaddr) bool

IsFDCostlyTransport returns true for transports that require a new file descriptor per connection created

func ResolveUnspecifiedAddress

func ResolveUnspecifiedAddress(resolve ma.Multiaddr, ifaceAddrs []ma.Multiaddr) ([]ma.Multiaddr, error)

ResolveUnspecifiedAddress expands an unspecified ip addresses (/ip4/0.0.0.0, /ip6/::) to use the known local interfaces. If ifaceAddr is nil, we request interface addresses from the network stack. (this is so you can provide a cached value if resolving many addrs)

func ResolveUnspecifiedAddresses

func ResolveUnspecifiedAddresses(unspecAddrs, ifaceAddrs []ma.Multiaddr) ([]ma.Multiaddr, error)

ResolveUnspecifiedAddresses expands unspecified ip addresses (/ip4/0.0.0.0, /ip6/::) to use the known local interfaces.

func Subtract

func Subtract(a, b []ma.Multiaddr) []ma.Multiaddr

Subtract filters out all addrs in b from a

func SubtractFilter

func SubtractFilter(addrs ...ma.Multiaddr) func(ma.Multiaddr) bool

SubtractFilter returns a filter func that filters all of the given addresses

func WANShareableAddrs

func WANShareableAddrs(inp []ma.Multiaddr) []ma.Multiaddr

WANShareableAddrs filters addresses based on whether they're shareable on WAN

Types

This section is empty.

Jump to

Keyboard shortcuts

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