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
- func AdminTokenFromDataDir(dataDir string) (string, error)
- type ControlPlaneTunables
- type Options
- type RouterTunables
- type Server
- func (s *Server) Addr() string
- func (s *Server) AdminToken() string
- func (s *Server) Close() error
- func (s *Server) JoinToken() string
- func (s *Server) JoinTokenPath() string
- func (s *Server) MintDeviceEnrollmentToken(ctx context.Context, ttl time.Duration, maxUsages int) (string, error)
- func (s *Server) PeerID() string
- func (s *Server) PublicURL() string
- func (s *Server) Start(ctx context.Context) error
Constants ¶
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 ¶
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
// 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 `sam-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 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.
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 (*Server) AdminToken ¶
AdminToken returns the resolved admin API token.
func (*Server) JoinToken ¶
JoinToken returns the resolved cluster join token, or "" when the server runs with DisableJoinToken.
func (*Server) JoinTokenPath ¶
JoinTokenPath is where an auto-generated join token is persisted, for `sam-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 `sam-one token revoke` ends a shared one early.