mycelium

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2026 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MyListenTCP = 9651
)
View Source
const (
	// MyceliumNSInf inside the namespace
	MyceliumNSInf = "nmy6"
)

Variables

View Source
var MyRange = net.IPNet{
	IP:   net.ParseIP("400::"),
	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 MyceliumInspection

type MyceliumInspection struct {
	PublicKey string `json:"publicKey"`
	Address   net.IP `json:"address"`
}

func (*MyceliumInspection) Gateway

func (m *MyceliumInspection) Gateway() (gw net.IPNet, err error)

Gateway derive the gateway IP from the mycelium IP in the /64 range.

func (*MyceliumInspection) IP

func (m *MyceliumInspection) IP() net.IP

IP return the address in the 400::/7 subnet allocated by mycelium

func (*MyceliumInspection) IPFor

func (m *MyceliumInspection) IPFor(b []byte) (net.IPNet, error)

IPFor 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 (*MyceliumInspection) Subnet

func (m *MyceliumInspection) Subnet() (subnet net.IPNet, err error)

Subnet return the 400::/64 subnet allocated by mycelium

type MyceliumNamespace

type MyceliumNamespace 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)
	// SetMyIP sets the mycelium ipv6 on the nmy6 iterface.
	SetMyIP(ip net.IPNet, gw net.IP) error
}

func NewMyNamespace

func NewMyNamespace(ns string) (MyceliumNamespace, error)

type MyceliumServer

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

MyceliumServer represent a mycelium server

func EnsureMycelium

func EnsureMycelium(ctx context.Context, privateKey ed25519.PrivateKey, ns MyceliumNamespace) (*MyceliumServer, error)

func NewMyceliumServer

func NewMyceliumServer(cfg *NodeConfig) *MyceliumServer

NewMyceliumServer create a new mycelium Server

func (*MyceliumServer) Ensure

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

Start creates a mycelium zinit service and starts it

func (*MyceliumServer) InspectMycelium

func (s *MyceliumServer) InspectMycelium() (inspection MyceliumInspection, err error)

func (*MyceliumServer) Reload

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

func (*MyceliumServer) Restart

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

func (*MyceliumServer) Tun

func (s *MyceliumServer) Tun() string

Tun return the name of the TUN interface created by mycelium

type NodeConfig

type NodeConfig struct {
	KeyFile string
	TunName string
	Peers   []string
	// contains filtered or unexported fields
}

func GenerateConfig

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

GenerateConfig creates a new mycelium configuration

func (*NodeConfig) AssignPeers added in v1.0.1

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

type Peers

type Peers []string

Peers is a peers list

func FindPeers added in v1.0.1

func FindPeers(ctx context.Context, filter ...Filter) (Peers, error)

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

Jump to

Keyboard shortcuts

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