standalone

package
v0.1.0-alpha.9 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2026 License: Apache-2.0 Imports: 20 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

This section is empty.

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
	// BiscuitTTL is the lifespan minted into issued biscuits.
	BiscuitTTL 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>/sam.db for sqlite.
	DBDSN string
	// JoinToken is the cluster join token; auto-generated and persisted in
	// DataDir when empty.
	JoinToken string
	// 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 PolicyConfigUpdateRequest payload.
	PolicyFile string
	// OIDCIssuer optionally enables full OIDC enrollment.
	OIDCIssuer       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 {
	// KeysSyncInterval is how often biscuit public keys are refreshed.
	KeysSyncInterval time.Duration
	// LeaseRenewInterval is how often the router renews its lease.
	LeaseRenewInterval 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
	// DHTProviderAddrTTL / DHTMaxRecordAge tune DHT record lifetimes.
	DHTProviderAddrTTL time.Duration
	DHTMaxRecordAge    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) JoinToken

func (s *Server) JoinToken() string

JoinToken returns the resolved cluster join token.

func (*Server) PeerID

func (s *Server) PeerID() string

PeerID returns the embedded router's peer ID.

func (*Server) Start

func (s *Server) Start(ctx context.Context) 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