yggdrasil

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2025 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	YggListenTCP       = 9943
	YggListenTLS       = 9944
	YggListenLinkLocal = 9945

	YggIface = "ygg0"
)

List of port used by yggdrasil

View Source
const (
	// YggNSInf inside the namespace
	YggNSInf = "nygg6"
)

Variables

View Source
var (
	YggRange = net.IPNet{
		IP:   net.ParseIP("200::"),
		Mask: net.CIDRMask(7, 128),
	}
)

Functions

func IPV4Only

func IPV4Only(ip net.IP) bool

IPV4Only is an IPFilter function that filters out non IPv4 address

Types

type Filter

type Filter func(ip net.IP) bool

func Exclude

func Exclude(ranges Ranges) Filter

Exclude ranges, return IPs that are NOT in the given ranges

func Include

func Include(ranges Ranges) Filter

Include ranges, return IPs that are IN one of the given ranges

type NodeConfig

type NodeConfig config.NodeConfig

NodeConfig wrapper around yggdrasil node config

func GenerateConfig

func GenerateConfig(privateKey ed25519.PrivateKey) (cfg NodeConfig)

GenerateConfig creates a new yggdrasil configuration and generate the box and signing key from the ed25519 Private key of the node this creates a mapping between a yggdrasil identity and the TFGrid identity

func (*NodeConfig) Address

func (n *NodeConfig) Address() (net.IP, error)

Address gets the address from the config

func (*NodeConfig) FindPeers

func (n *NodeConfig) FindPeers(ctx context.Context, filter ...Filter) error

type Peers

type Peers []string

Peers is a peers list

func (Peers) Ups

func (p Peers) Ups(filter ...Filter) (Peers, error)

Ups return all the peers that are marked up from the PeerList p

type Ranges

type Ranges []net.IPNet

Ranges is a list of net.IPNet

type YggServer

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

YggServer represent a yggdrasil server

func EnsureYggdrasil

func EnsureYggdrasil(ctx context.Context, privateKey ed25519.PrivateKey, ns YggdrasilNamespace) (*YggServer, error)

func NewYggServer

func NewYggServer(cfg *NodeConfig) *YggServer

NewYggServer create a new yggdrasil Server

func (*YggServer) Address

func (s *YggServer) Address() (net.IP, error)

Address return the address in the 200::/7 subnet allocated by yggdrasil

func (*YggServer) Ensure

func (s *YggServer) Ensure(z *zinit.Client, ns string) error

Start creates an yggdrasil zinit service and starts it

func (*YggServer) Gateway

func (s *YggServer) Gateway() (net.IPNet, error)

Gateway return the first IP of the 300::/64 subnet allocated by yggdrasil

func (*YggServer) NodeID

func (s *YggServer) NodeID() (ed25519.PublicKey, error)

NodeID returns the yggdrasil node ID of s

func (*YggServer) Reload

func (s *YggServer) Reload(z *zinit.Client) error

func (*YggServer) Restart

func (s *YggServer) Restart(z *zinit.Client) error

func (*YggServer) Subnet

func (s *YggServer) Subnet() (net.IPNet, error)

Subnet return the 300::/64 subnet allocated by yggdrasil

func (*YggServer) SubnetFor

func (s *YggServer) SubnetFor(b []byte) (net.IPNet, error)

SubnetFor return an IP address out of the node allocated subnet by hasing b and using it to generate the last 64 bits of the IPV6 address

func (*YggServer) Tun

func (s *YggServer) Tun() string

Tun return the name of the TUN interface created by yggdrasil

type YggdrasilNamespace

type YggdrasilNamespace interface {
	Name() string
	// IsIPv4Only checks if namespace has NO public ipv6 on any of its interfaces
	IsIPv4Only() (bool, error)
	// GetIPs return a list of all IPv6 inside this namespace.
	GetIPs() ([]net.IPNet, error)
	// SetYggIP sets the ygg ipv6 on the nygg6 iterface.
	SetYggIP(ip net.IPNet, gw net.IP) error
}

func NewYggdrasilNamespace

func NewYggdrasilNamespace(ns string) (YggdrasilNamespace, error)

Jump to

Keyboard shortcuts

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