meshpath

package
v0.8.6 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package meshpath answers one question for the ingress and application controllers: can this control plane reach a remote node's published ports over the WireGuard mesh right now, and on which address.

Index

Constants

View Source
const (
	DefaultDatabasePortMin = 21000
	DefaultDatabasePortMax = 21999
)

Default range for database mesh ports, overridable with APP_MESH_DB_PORT_MIN and APP_MESH_DB_PORT_MAX.

View Source
const StaleAfter = 3 * time.Minute

StaleAfter is how old a WireGuard handshake may be before the path counts as down. Persistent keepalive keeps a healthy peer well inside it.

Variables

This section is empty.

Functions

func DatabasePortRange

func DatabasePortRange(lookup func(string) (string, bool)) (int, int)

DatabasePortRange reads the database mesh port range, falling back to the defaults when either bound is unset or the pair is invalid.

func ValidateBindIP

func ValidateBindIP(ip string) error

ValidateBindIP is the single guard every mesh bind goes through: only a concrete unicast address may be bound, never a wildcard, loopback or multicast one, so a mesh bind can never widen a port to every interface.

Types

type EndpointResolver

type EndpointResolver interface {
	Endpoint(ctx context.Context, nodeID string) (Path, error)
}

EndpointResolver reports the mesh address services on a node are published on and dialed at, the control plane's own node included.

type NodeStore

type NodeStore interface {
	GetNode(ctx context.Context, id string) (*store.Node, error)
}

NodeStore is the slice of the store the tracker needs.

type Path

type Path struct {
	// Local is true for the control plane's own node, which needs no mesh.
	Local bool
	// Usable is true when Address can be dialed and bound to right now.
	Usable bool
	// Address is the node's mesh IP, set only when Usable.
	Address string
	// NoMesh is true when the node has no mesh to reach it over (mesh off, or
	// the node never joined), so callers may use its ordinary address.
	NoMesh bool
	// Reason says why the path is not usable, with the next action.
	Reason string
}

Path is the mesh route from this control plane to one node.

type Resolver

type Resolver interface {
	Path(ctx context.Context, nodeID string) (Path, error)
}

Resolver reports the mesh path to a node.

type StatusReader

type StatusReader interface {
	Status(ctx context.Context) (network.Status, error)
}

StatusReader is the slice of network.Mesh the tracker needs.

type Tracker

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

Tracker derives Paths from the control plane's live WireGuard device.

func NewTracker

func NewTracker(localID string, mesh StatusReader, nodes NodeStore) *Tracker

NewTracker builds a Tracker. mesh may be nil when mesh networking is off.

func (*Tracker) Endpoint

func (t *Tracker) Endpoint(ctx context.Context, nodeID string) (Path, error)

Endpoint is Path, except the control plane's own node also resolves to its mesh address, since remote nodes reach services there over the mesh.

func (*Tracker) LocalID

func (t *Tracker) LocalID() string

LocalID is the control plane's own node ID, "" when mesh is off.

func (*Tracker) Path

func (t *Tracker) Path(ctx context.Context, nodeID string) (Path, error)

Path implements Resolver.

Jump to

Keyboard shortcuts

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