mesh

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: Apache-2.0 Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package mesh runs the controller side of private networking (§8): it allocates each node a WireGuard address and a container subnet (IPAM, §8.2) and sends every agent its view of the full mesh.

Index

Constants

View Source
const (
	// ListenPort is the WireGuard UDP port on every node.
	ListenPort = 51820
	// ControllerNode always gets mesh index 1 (10.90.0.1).
	ControllerNode = "ctl-0"
	// Cooldown keeps released indexes out of the pool.
	Cooldown = time.Hour
	// TopicUpdated carries a NodeView when a node's mesh state changes.
	TopicUpdated = "mesh.updated"
)
View Source
const ConfirmTimeout = 60

ConfirmTimeout is how long an agent waits for the controller to confirm a firewall change before rolling it back (§8.3).

Variables

View Source
var (
	MeshCIDR      = netip.MustParsePrefix("10.90.0.0/16")
	ContainerCIDR = netip.MustParsePrefix("10.91.0.0/16")
	ServiceCIDR   = netip.MustParsePrefix("10.92.0.0/16")
)

Address plan (§8).

Functions

func ConfigFor

func ConfigFor(self store.NodeNetwork, all []store.NodeNetwork, gen uint64) *agentv1.NetworkConfig

ConfigFor builds self's view: every other member with a key is a peer.

func FirewallFor

func FirewallFor(self store.NodeNetwork, all []store.NodeNetwork, policies []store.FirewallPolicy, opts Options) *agentv1.Firewall

FirewallFor builds a node's host firewall: built-in rules plus every policy that targets it.

func MeshAddr

func MeshAddr(i int) netip.Addr

MeshAddr maps a mesh index to its address (10.90.hi.lo).

func Subnet

func Subnet(i int) netip.Prefix

Subnet maps a subnet index to its /24 (10.91.i.0/24).

Types

type Manager

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

func NewManager

func NewManager(st *store.Store, gw *agentgw.Gateway, bus *events.Bus, log *slog.Logger, publicIP PublicIP, opts Options) *Manager

func (*Manager) Changed

func (m *Manager) Changed(ctx context.Context)

Changed re-sends every node its configuration (e.g. after a firewall policy change).

func (*Manager) Hooks

func (m *Manager) Hooks() agentgw.Hooks

func (*Manager) IsMember

func (m *Manager) IsMember(nodeID string) bool

IsMember reports whether the node's agent runs mesh networking.

func (*Manager) List

func (m *Manager) List(ctx context.Context) ([]NodeView, error)

List returns every member's mesh state.

func (*Manager) NetworkReady

func (m *Manager) NetworkReady(nodeID string) bool

NetworkReady reports whether tasks can be placed on the node: either it is not a mesh member (single-node development), or its network is applied.

func (*Manager) NodeConfig

func (m *Manager) NodeConfig(ctx context.Context, nodeID string) (*agentv1.NetworkConfig, error)

NodeConfig returns the configuration a node would get now (for the effective-rules view).

func (*Manager) PathTo added in v0.2.4

func (m *Manager) PathTo(ctx context.Context, nodeID string) string

PathTo describes the controller's WireGuard link to a node, for messages about tasks the controller cannot reach ("" when unknown).

func (*Manager) Run

func (m *Manager) Run(ctx context.Context)

Run rebroadcasts when nodes are removed.

type NodeView

type NodeView struct {
	NodeID          string     `json:"nodeId"`
	Name            string     `json:"name"`
	Address         string     `json:"address"`
	Subnet          string     `json:"subnet"`
	Endpoint        string     `json:"endpoint"`
	PublicKey       string     `json:"publicKey"`
	Mode            string     `json:"mode"`
	Generation      uint64     `json:"generation"`
	AppliedGen      uint64     `json:"appliedGeneration"`
	Error           string     `json:"error"`
	FirewallPending bool       `json:"firewallPending"`
	Drift           uint64     `json:"driftCorrections"`
	Peers           []PeerView `json:"peers"`
	StatusUpdatedAt *time.Time `json:"statusUpdatedAt"`
}

NodeView is a node's mesh state for the API.

type Options

type Options struct {
	// ControllerPorts are opened to everyone on ctl-0 (HTTP, HTTPS, agent gateway).
	ControllerPorts []string
	// Firewall turns the host firewall on.
	Firewall bool
	// IsEdge reports edge nodes, which open HTTP and HTTPS (§8.5).
	IsEdge func(nodeID string) bool
	// PublicPorts are extra ports Traefik serves publicly on the
	// controller and edge nodes (public databases, Phase 12e; public
	// service ports, Phase 15c).
	PublicPorts func() []PublicPort
}

Options configure the firewall rules the controller adds by itself.

type PeerView

type PeerView struct {
	NodeID        string     `json:"nodeId"`
	Name          string     `json:"name"`
	Endpoint      string     `json:"endpoint"`
	LastHandshake *time.Time `json:"lastHandshake"`
	RxBytes       uint64     `json:"rxBytes"`
	TxBytes       uint64     `json:"txBytes"`
	RTTMillis     float64    `json:"rttMs"`
}

PeerView is one peer link as reported by an agent.

type PublicIP

type PublicIP func(ctx context.Context) (string, error)

PublicIP returns the controller's public address (for ctl-0's endpoint).

type PublicPort

type PublicPort struct {
	Port     string // number or range
	Protocol string // tcp (default) or udp
	Sources  []string
	// Kind names the rule ("database", "service").
	Kind string
}

PublicPort is a port the host firewall opens on the controller and edge nodes.

Jump to

Keyboard shortcuts

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