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

standalone

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Overview

Package standalone wires the control plane, the libp2p router and the shared SQL store into one process serving a single public port: the router's WebSocket listener carries libp2p upgrades while every other HTTP request falls through to the control-plane mux. The embedded router keeps its stock control-plane client, pointed at a loopback-only listener, so no component grows in-process shortcuts.

Index

Constants

View Source
const (

	// DeviceTokenTTL bounds a device enrollment token: long enough to walk
	// over and scan the QR code, short enough that a screenshot of it goes
	// stale.
	DeviceTokenTTL = time.Hour
)

Variables

This section is empty.

Functions

func AdminTokenFromDataDir

func AdminTokenFromDataDir(dataDir string) (string, error)

AdminTokenFromDataDir reads the admin token a previous run persisted in dataDir, so CLI subcommands can authenticate without re-supplying it.

Types

type ControlPlaneTunables

type ControlPlaneTunables struct {
	// LeaseDuration bounds how long a router lease stays valid.
	LeaseDuration time.Duration
	// KeyRotationInterval is how often the biscuit signing key rotates.
	KeyRotationInterval time.Duration
	// KeyGracePeriod keeps rotated-out keys valid for verification.
	KeyGracePeriod time.Duration
	// SigningKeyPath is the operator's PEM file of signing keys; see
	// controlplane.Options.SigningKeyPath. Empty lets the control plane
	// generate and rotate its own.
	SigningKeyPath string
	// DHTReplication and DHTReprovideInterval are the mesh's directory
	// parameters; see controlplane.Options.
	DHTReplication       int
	DHTReprovideInterval time.Duration
	// BiscuitTTL is the lifespan minted into issued biscuits.
	BiscuitTTL time.Duration
	// WorkloadSessionTTL is how long a workload-issuer enrollment stays
	// refreshable without presenting a fresh platform JWT on /refresh.
	WorkloadSessionTTL time.Duration
	// NodeRetention is how long a node record is kept after its session
	// expired, or after its last refresh for a bootstrap enrollment, before
	// the control plane deletes it.
	NodeRetention time.Duration
	// EphemeralNodeRetention is NodeRetention for a node an ephemeral
	// bootstrap token enrolled.
	EphemeralNodeRetention time.Duration
	// ManualEnrollment queues bootstrap enrollments for admin approval
	// instead of auto-approving them.
	ManualEnrollment bool
}

ControlPlaneTunables are the embedded control plane's operator knobs.

type Options

type Options struct {
	// BindAddress is the host:port of the single public listener. The host
	// must be empty or an IP literal.
	BindAddress string
	// ExternalURL is the public URL nodes reach this server on; it is turned
	// into the ws/wss multiaddr the router advertises. Optional.
	ExternalURL string
	// P2PListen holds optional extra native libp2p listen multiaddrs.
	P2PListen []string
	// DataDir stores the SQLite database, the router identity key and the
	// generated token files.
	DataDir string
	// DBDriver selects "sqlite" (default) or "postgres".
	DBDriver string
	// DBDSN is the database connection string; defaults to
	// <DataDir>/agentmesh.db for sqlite.
	DBDSN string
	// JoinToken is the cluster join token; auto-generated and persisted in
	// DataDir when empty.
	JoinToken string
	// DisableJoinToken runs without any standing join token: devices then
	// enroll only with explicitly minted bootstrap tokens or through OIDC.
	// The right setting for a fleet; the default keeps `agentmesh-node join` on a
	// laptop zero-config.
	DisableJoinToken bool
	// AdminToken protects the admin REST API; auto-generated and persisted in
	// DataDir when empty.
	AdminToken string
	// PolicyFile optionally seeds the mesh policy on first boot from a
	// protojson PolicyConfig payload.
	PolicyFile string
	// OIDCIssuer optionally enables full OIDC enrollment.
	OIDCIssuer       string
	WorkloadIssuer   string
	AllowedAudiences []string
	// OIDCClientID is the OAuth client id advertised via /info.
	OIDCClientID string

	// ControlPlane and Router forward operator tunables to the embedded
	// components; zero values keep each component's defaults.
	ControlPlane ControlPlaneTunables
	Router       RouterTunables
}

Options configures the standalone all-in-one server.

func (*Options) Default

func (o *Options) Default()

Default fills unset options with development-friendly values.

func (*Options) Validate

func (o *Options) Validate() error

Validate rejects option combinations Start could not honor.

type RouterTunables

type RouterTunables struct {
	// ControlPlaneSyncInterval is how often the router renews its lease and
	// pulls keys, routers, bans and policy from the control plane.
	ControlPlaneSyncInterval time.Duration
	// LowWaterMark / HighWaterMark bound the connection manager.
	LowWaterMark  int
	HighWaterMark int
	// ConnsPerSourceIP scales libp2p's per-source-IP budgets; defaults to
	// the connection manager high watermark (proxied deployments share
	// source IPs, so the global cap should be what binds).
	ConnsPerSourceIP int
	// RelayLimitDuration / RelayLimitData cap each relayed connection.
	RelayLimitDuration time.Duration
	RelayLimitData     router.ByteSize
	// ShutdownLeaseTTL is the lease the embedded router asks for as it stops;
	// see router.Options.ShutdownLeaseTTL.
	ShutdownLeaseTTL time.Duration
	// AuthDeadline closes inbound connections that do not pass the handshake
	// in time; see router.Options.AuthDeadline.
	AuthDeadline time.Duration
	// DisallowLoopback stops advertising loopback addresses (useful on
	// public deployments; the default keeps local development working).
	DisallowLoopback bool
}

RouterTunables are the embedded router's operator knobs.

type Server

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

Server is the running all-in-one instance.

func New

func New(opts Options) (*Server, error)

New validates the options and prepares a standalone server.

func (*Server) Addr

func (s *Server) Addr() string

Addr returns the public host:port actually bound (useful with port 0).

func (*Server) AdminToken

func (s *Server) AdminToken() string

AdminToken returns the resolved admin API token.

func (*Server) Close

func (s *Server) Close() error

Close shuts down the router, control plane and store.

func (*Server) IngressURL added in v0.2.0

func (s *Server) IngressURL() string

IngressURL is the public base URL under which the embedded router serves external HTTP ingress on the single port.

func (*Server) JoinToken

func (s *Server) JoinToken() string

JoinToken returns the resolved cluster join token, or "" when the server runs with DisableJoinToken.

func (*Server) JoinTokenPath

func (s *Server) JoinTokenPath() string

JoinTokenPath is where an auto-generated join token is persisted, for `agentmesh-node join --bootstrap-token-path`.

func (*Server) MintDeviceEnrollmentToken

func (s *Server) MintDeviceEnrollmentToken(ctx context.Context, ttl time.Duration, maxUsages int) (string, error)

MintDeviceEnrollmentToken registers a fresh node bootstrap token good for maxUsages enrollments (1 = burned by the first device; more lets one code on a projector enroll a room) and returns its plaintext once. Unlike the join token it is never persisted; a device that missed the window simply gets a new one, and `agentmesh-one token revoke` ends a shared one early.

func (*Server) PeerID

func (s *Server) PeerID() string

PeerID returns the embedded router's peer ID.

func (*Server) PublicURL

func (s *Server) PublicURL() string

PublicURL is the base URL clients should reach this server on: the configured external URL, else the bound listener over plain HTTP.

func (*Server) ReloadOperatorSigningKeys added in v0.1.1

func (s *Server) ReloadOperatorSigningKeys()

ReloadOperatorSigningKeys re-reads the operator's signing key file now instead of at the watcher's next tick. A no-op without --signing-key-path.

func (*Server) Start

func (s *Server) Start(ctx context.Context) (retErr error)

Start boots the store, the control plane on a loopback-only listener, and the router owning the single public port. It returns once the mesh accepts enrollments.

Jump to

Keyboard shortcuts

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