Help us shape the future of Go! Take the 2026 Go Developer Survey

control

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: AGPL-3.0 Imports: 24 Imported by: 0

Documentation

Overview

Package control implements the agent-facing control plane.

Index

Constants

This section is empty.

Variables

View Source
var DefaultDNS = DNSConfig{MagicDNS: true, Domain: "mesh.internal", Split: []SplitDNS{}}

DefaultDNS is used until an admin changes it.

Functions

This section is empty.

Types

type DNSConfig

type DNSConfig struct {
	// MagicDNS makes agents answer <node>.<Domain> at MagicDNSAddr.
	MagicDNS bool   `json:"magicDNS"`
	Domain   string `json:"domain"`
	// Split sends queries for these domains to specific resolvers.
	Split []SplitDNS `json:"split"`
}

DNSConfig is the mesh's DNS configuration, stored as JSON.

func (*DNSConfig) Validate

func (c *DNSConfig) Validate() error

Validate normalises and checks the configuration.

type Options

type Options struct {
	// STUNPort is the UDP port of the STUN server; 0 if disabled.
	STUNPort uint16
	// RelayEnabled reports whether the packet relay is served.
	RelayEnabled bool
}

Options describes the NAT-traversal services the coordinator offers, which are announced to nodes in every netmap.

type PeerPath

type PeerPath struct {
	NodeID    string
	Path      string
	LatencyMs float64
}

PeerPath is how a node reaches one of its peers.

type PolicyError

type PolicyError struct{ Errors []string }

PolicyError lists why a policy was rejected.

func (*PolicyError) Error

func (e *PolicyError) Error() string

type Service

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

Service implements controlv1connect.ControlServiceHandler.

func NewService

func NewService(s *store.Store, prefix netip.Prefix, opts Options, log *slog.Logger) *Service

NewService returns a control service allocating addresses from prefix.

func (*Service) ApproveRoutes

func (s *Service) ApproveRoutes(ctx context.Context, nodeID string, routes []netip.Prefix) (store.Node, error)

ApproveRoutes replaces a node's approved routes.

func (*Service) Compiled

func (s *Service) Compiled(ctx context.Context) (*policy.Compiled, []store.Node, error)

Compiled returns the policy compiled against the current nodes.

func (*Service) DNS

func (s *Service) DNS(ctx context.Context) (DNSConfig, error)

DNS returns the DNS configuration.

func (*Service) Handler

func (s *Service) Handler() (string, http.Handler)

Handler returns the mount path and HTTP handler for the service.

func (*Service) KeyExpiry

func (s *Service) KeyExpiry(ctx context.Context) (time.Duration, error)

KeyExpiry returns how long node keys last; zero means forever.

func (*Service) Notify

func (s *Service) Notify()

Notify tells every connected node to refresh its netmap, e.g. after an administrator changed something.

func (*Service) Online

func (s *Service) Online(nodeID string) bool

Online reports whether the node currently has an open control stream.

func (*Service) Options

func (s *Service) Options() Options

Options returns the NAT-traversal options announced to nodes.

func (*Service) Policy

func (s *Service) Policy(ctx context.Context) (*policy.Policy, string, error)

Policy returns the access-control policy and its source text. It reads the stored text every time (so changes made with the coordinator's CLI apply too) and parses it only when it changed.

func (*Service) Prefix

func (s *Service) Prefix() netip.Prefix

Prefix returns the mesh network prefix.

func (*Service) SetDNS

func (s *Service) SetDNS(ctx context.Context, c DNSConfig) (DNSConfig, error)

SetDNS validates, stores and applies a DNS configuration.

func (*Service) SetPolicy

func (s *Service) SetPolicy(ctx context.Context, text string) (*policy.Policy, error)

SetPolicy validates, stores and applies a new policy. Policy tests are checked against the current nodes; failures reject the change.

func (*Service) Subscribe

func (s *Service) Subscribe() (<-chan struct{}, func())

Subscribe returns a channel that receives a value (coalesced) whenever the mesh changes, and a function to stop listening.

func (*Service) Topology

func (s *Service) Topology() map[string][]PeerPath

Topology returns the latest peer paths reported by each online node.

type SplitDNS

type SplitDNS struct {
	Domain    string   `json:"domain"`
	Resolvers []string `json:"resolvers"`
}

SplitDNS routes one domain to its resolvers.

Jump to

Keyboard shortcuts

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