Documentation ¶
Overview ¶
Package address contains the types used by yggdrasil to represent IPv6 addresses or prefixes, as well as functions for working with these types. Of particular importance are the functions used to derive addresses or subnets from a NodeID, or to get the NodeID and bitmask of the bits visible from an address, which is needed for DHT searches.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetPrefix ¶
func GetPrefix() [1]byte
GetPrefix returns the address prefix used by yggdrasil. The current implementation requires this to be a multiple of 8 bits + 7 bits. The 8th bit of the last byte is used to signal nodes (0) or /64 prefixes (1). Nodes that configure this differently will be unable to communicate with each other using IP packets, though routing and the DHT machinery *should* still work.
Types ¶
type Address ¶
type Address [16]byte
Address represents an IPv6 address in the yggdrasil address range.
func AddrForNodeID ¶
AddrForNodeID takes a *NodeID as an argument and returns an *Address. This address begins with the contents of GetPrefix(), with the last bit set to 0 to indicate an address. The following 8 bits are set to the number of leading 1 bits in the NodeID. The NodeID, excluding the leading 1 bits and the first leading 0 bit, is truncated to the appropriate length and makes up the remainder of the address.
func (*Address) GetNodeIDLengthString ¶ added in v0.3.14
GetNodeIDLengthString returns a string representation of the known bits of the NodeID, along with the number of known bits, for use with yggdrasil.Dialer's Dial and DialContext functions.
func (*Address) GetNodeIDandMask ¶
GetNodeIDandMask returns two *NodeID. The first is a NodeID with all the bits known from the Address set to their correct values. The second is a bitmask with 1 bit set for each bit that was known from the Address. This is used to look up NodeIDs in the DHT and tell if they match an Address.
type Subnet ¶
type Subnet [8]byte
Subnet represents an IPv6 /64 subnet in the yggdrasil subnet range.
func SubnetForNodeID ¶
SubnetForNodeID takes a *NodeID as an argument and returns an *Address. This subnet begins with the address prefix, with the last bit set to 1 to indicate a prefix. The following 8 bits are set to the number of leading 1 bits in the NodeID. The NodeID, excluding the leading 1 bits and the first leading 0 bit, is truncated to the appropriate length and makes up the remainder of the subnet.
func (*Subnet) GetNodeIDLengthString ¶ added in v0.3.14
GetNodeIDLengthString returns a string representation of the known bits of the NodeID, along with the number of known bits, for use with yggdrasil.Dialer's Dial and DialContext functions.
func (*Subnet) GetNodeIDandMask ¶
GetNodeIDandMask returns two *NodeID. The first is a NodeID with all the bits known from the Subnet set to their correct values. The second is a bitmask with 1 bit set for each bit that was known from the Subnet. This is used to look up NodeIDs in the DHT and tell if they match a Subnet.