Documentation ¶
Overview ¶
package netutil provides common utility functions for networking.
Index ¶
- Constants
- func AssignToPrefix(prefix netip.Prefix, publicKey crypto.PublicKey) netip.Prefix
- func GenerateULA() (netip.Prefix, error)
- func GenerateULAWithKey(key crypto.PublicKey) (netip.Prefix, netip.Addr)
- func GenerateULAWithSeed(psk []byte) netip.Prefix
- func ParsePortRange(s string) (start int, end int, err error)
- func Ping(ctx context.Context, addr netip.Addr) error
- func ResolveTCPAddr(ctx context.Context, lookup string, maxRetries int) (net.Addr, error)
Constants ¶
const ( // DefaultULABits are the default bits used for the IPv6 address // space of the network. DefaultULABits = 48 // DefaultNodeBits are the default bits used for the IPv6 address // space of each node. DefaultNodeBits = 112 )
Variables ¶
This section is empty.
Functions ¶
func AssignToPrefix ¶
AssignToPrefix assigns a /112 prefix within a /48 prefix using a public key. It does not check that the given prefix is a valid /48 prefix.
func GenerateULA ¶
GenerateULA generates a unique local address with a /48 prefix according to RFC 4193. The network is returned as a netip.Prefix.
func GenerateULAWithKey ¶
GenerateULAWithKey generates a unique local address with a /48 prefix using the key bytes as a seed. The network is returned as a netip.Prefix. It then computes another /112 prefix for the given public key's wireguard key. It returns the /112 prefix as the first /128 address within it.
func GenerateULAWithSeed ¶
GenerateULAWithSeed generates a unique local address with a /48 prefix using a seed value. The network is returned as a netip.Prefix.
func ParsePortRange ¶
ParsePortRange parses a port range string.
Types ¶
This section is empty.