endpoints

package
v0.13.5 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DetectPublicAddresses

func DetectPublicAddresses(ctx context.Context) ([]netip.Addr, error)

DetectPublicAddresses detects the public addresses of the machine using the opendns resolver service.

Types

type DetectOpts

type DetectOpts struct {
	// DetectIPv6 enables IPv6 detection.
	DetectIPv6 bool
	// DetectPrivate enables private address detection.
	DetectPrivate bool
	// AllowRemoteDetection enables remote address detection.
	AllowRemoteDetection bool
	// SkipInterfaces contains a list of interfaces to skip.
	SkipInterfaces []string
}

DetectOpts contains options for endpoint detection.

type PrefixList

type PrefixList []netip.Prefix

PrefixList wraps a list of network prefixes with added functionality.

func Detect

func Detect(ctx context.Context, opts DetectOpts) (PrefixList, error)

Detect detects endpoints for this machine.

func (PrefixList) AddrPorts

func (a PrefixList) AddrPorts(port uint16) []netip.AddrPort

func (PrefixList) AddrStrings

func (a PrefixList) AddrStrings() []string

func (PrefixList) Contains

func (a PrefixList) Contains(addr netip.Addr) bool

func (PrefixList) FirstPublicAddr added in v0.10.1

func (a PrefixList) FirstPublicAddr() netip.Addr

func (PrefixList) Len

func (a PrefixList) Len() int

func (PrefixList) Less

func (a PrefixList) Less(i, j int) bool

Sort by Public addresses first. Then IPv4 addresses and finally IPv6 addresses.

func (PrefixList) PrivateAddrs added in v0.12.0

func (a PrefixList) PrivateAddrs() []netip.Addr

func (PrefixList) PublicAddrs added in v0.12.0

func (a PrefixList) PublicAddrs() []netip.Addr

func (PrefixList) Strings

func (a PrefixList) Strings() []string

func (PrefixList) Swap

func (a PrefixList) Swap(i, j int)

func (PrefixList) WebmeshMultiaddrs

func (a PrefixList) WebmeshMultiaddrs(proto string, port uint16, peerID peer.ID) []ma.Multiaddr

Jump to

Keyboard shortcuts

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