addressmanager

package
v3.1.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// GetAddressesMax is the most addresses that we will send in response
	// to a getAddress (in practise the most addresses we will return from a
	// call to AddressCache()).
	GetAddressesMax = 2500
)

Variables

View Source
var ErrAddressNotFound = errors.New("address not found")

ErrAddressNotFound is an error returned from some functions when a given address is not found in the address manager

Functions

func IsIPv4

func IsIPv4(na *appmessage.NetAddress) bool

IsIPv4 returns whether or not the given address is an IPv4 address.

func IsLocal

func IsLocal(na *appmessage.NetAddress) bool

IsLocal returns whether or not the given address is a local address.

func IsRFC1918

func IsRFC1918(na *appmessage.NetAddress) bool

IsRFC1918 returns whether or not the passed address is part of the IPv4 private network address space as defined by RFC1918 (10.0.0.0/8, 172.16.0.0/12, or 192.168.0.0/16).

func IsRFC2544

func IsRFC2544(na *appmessage.NetAddress) bool

IsRFC2544 returns whether or not the passed address is part of the IPv4 address space as defined by RFC2544 (198.18.0.0/15)

func IsRFC3849

func IsRFC3849(na *appmessage.NetAddress) bool

IsRFC3849 returns whether or not the passed address is part of the IPv6 documentation range as defined by RFC3849 (2001:DB8::/32).

func IsRFC3927

func IsRFC3927(na *appmessage.NetAddress) bool

IsRFC3927 returns whether or not the passed address is part of the IPv4 autoconfiguration range as defined by RFC3927 (169.254.0.0/16).

func IsRFC3964

func IsRFC3964(na *appmessage.NetAddress) bool

IsRFC3964 returns whether or not the passed address is part of the IPv6 to IPv4 encapsulation range as defined by RFC3964 (2002::/16).

func IsRFC4193

func IsRFC4193(na *appmessage.NetAddress) bool

IsRFC4193 returns whether or not the passed address is part of the IPv6 unique local range as defined by RFC4193 (FC00::/7).

func IsRFC4380

func IsRFC4380(na *appmessage.NetAddress) bool

IsRFC4380 returns whether or not the passed address is part of the IPv6 teredo tunneling over UDP range as defined by RFC4380 (2001::/32).

func IsRFC4843

func IsRFC4843(na *appmessage.NetAddress) bool

IsRFC4843 returns whether or not the passed address is part of the IPv6 ORCHID range as defined by RFC4843 (2001:10::/28).

func IsRFC4862

func IsRFC4862(na *appmessage.NetAddress) bool

IsRFC4862 returns whether or not the passed address is part of the IPv6 stateless address autoconfiguration range as defined by RFC4862 (FE80::/64).

func IsRFC5737

func IsRFC5737(na *appmessage.NetAddress) bool

IsRFC5737 returns whether or not the passed address is part of the IPv4 documentation address space as defined by RFC5737 (192.0.2.0/24, 198.51.100.0/24, 203.0.113.0/24)

func IsRFC6052

func IsRFC6052(na *appmessage.NetAddress) bool

IsRFC6052 returns whether or not the passed address is part of the IPv6 well-known prefix range as defined by RFC6052 (64:FF9B::/96).

func IsRFC6145

func IsRFC6145(na *appmessage.NetAddress) bool

IsRFC6145 returns whether or not the passed address is part of the IPv6 to IPv4 translated address range as defined by RFC6145 (::FFFF:0:0:0/96).

func IsRFC6598

func IsRFC6598(na *appmessage.NetAddress) bool

IsRFC6598 returns whether or not the passed address is part of the IPv4 shared address space specified by RFC6598 (100.64.0.0/10)

func IsRoutable

func IsRoutable(na *appmessage.NetAddress, acceptUnroutable bool) bool

func IsValid

func IsValid(na *appmessage.NetAddress) bool

IsValid returns whether or not the passed address is valid. The address is considered invalid under the following circumstances: IPv4: It is either a zero or all bits set address. IPv6: It is either a zero or RFC3849 documentation address.

Types

type AddressManager

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

func New

func New(cfg *Config, database database.Database) (*AddressManager, error)

func (*AddressManager) AddAddresses

func (am *AddressManager) AddAddresses(addresses ...*appmessage.NetAddress) error

func (*AddressManager) Addresses

func (am *AddressManager) Addresses() []*appmessage.NetAddress

Addresses returns all addresses

func (*AddressManager) Ban

func (am *AddressManager) Ban(addressToBan *appmessage.NetAddress) error

Ban marks the given address as banned

func (*AddressManager) BestLocalAddress

func (am *AddressManager) BestLocalAddress(remoteAddress *appmessage.NetAddress) *appmessage.NetAddress

BestLocalAddress returns the most appropriate local address to use for the given remote address.

func (*AddressManager) IsBanned

func (am *AddressManager) IsBanned(address *appmessage.NetAddress) (bool, error)

IsBanned returns true if the given address is marked as banned

type AddressPriority

type AddressPriority int
const (
	// InterfacePrio signifies the address is on a local interface
	InterfacePrio AddressPriority = iota

	// BoundPrio signifies the address has been explicitly bounded to.
	BoundPrio

	// UpnpPrio signifies the address was obtained from UPnP.
	UpnpPrio

	// HTTPPrio signifies the address was obtained from an external HTTP service.
	HTTPPrio

	// ManualPrio signifies the address was provided by --externalip.
	ManualPrio
)

type Config

type Config struct {
	AcceptUnroutable bool
	DefaultPort      string
	ExternalIPs      []string
	Listeners        []string
	Lookup           func(string) ([]net.IP, error)
}

Config is a descriptor which specifies the AddressManager instance configuration.

func NewConfig

func NewConfig(cfg *infraconfig.Config) *Config

NewConfig returns a new address manager Config.

Jump to

Keyboard shortcuts

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