api

package
v0.25.0 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2026 License: GPL-3.0 Imports: 55 Imported by: 0

Documentation

Overview

Package api implements the Panel's HTTP API: routing, middleware, and handlers for auth, the game spec catalog, and user administration. It is transport over the store + rbac packages and holds no business state of its own.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*Server)

Option customizes a Server at construction time.

func WithCA

func WithCA(cert, key []byte) Option

WithCA pre-loads the Agent-enrollment CA signing material (e.g. a self-generated CA resolved at startup). When set, it takes precedence over file-based loading.

func WithClientTLSBytes added in v0.5.1

func WithClientTLSBytes(cert, key, ca []byte) Option

WithClientTLSBytes provides Panel client TLS material as raw PEM bytes, used when the Panel auto-issues its own client cert at startup against the Agent-enrollment CA (see cmd/panel/main.go). Takes precedence over the KRAKEN_TLS_CERT/KEY/CA file-based path.

func WithRestart

func WithRestart(fn func()) Option

WithRestart wires a callback the API can use to request a process restart.

type Server

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

Server holds the API dependencies and exposes an http.Handler.

func New

func New(cfg *config.Config, st store.Store, logger *slog.Logger, opts ...Option) *Server

New constructs a Server and wires its routes. The Agent connection pool is secure by default: when TLS material is configured (either via KRAKEN_TLS_* files or via WithClientTLSBytes) it dials Agents over mutual TLS; only an explicitly cert-less (dev) config falls back to insecure, with a warning.

func (*Server) AutoRegisterLocalNode

func (s *Server) AutoRegisterLocalNode(ctx context.Context)

AutoRegisterLocalNode registers the co-located Agent as the "local" node and brings it online, so a fresh single-host install reaches a running server with no CLI. It is a no-op when quickstart is disabled or any node already exists (idempotent across restarts, and it never interferes with a real fleet).

func (*Server) Close

func (s *Server) Close() error

Close releases resources held by the server (Agent gRPC connections).

func (*Server) Handler

func (s *Server) Handler() http.Handler

Handler returns the root HTTP handler.

func (*Server) StartNodeReconciler added in v0.13.0

func (s *Server) StartNodeReconciler(ctx context.Context, interval time.Duration)

StartNodeReconciler launches a background loop that polls every registered node's Agent and persists its health (online / partial / offline).

Without it a node's status only moved when something asked for it — the Ping button, the setup wizard, or the connect-node flow — so a host whose Agent died (or whose Docker stopped) went on reading "online" indefinitely, and the scheduler kept sending servers to it. The interval is deliberately slower than the server reconciler: each pass is a gRPC round trip per node that also re-pushes node config and checks cert expiry.

func (*Server) StartReconciler

func (s *Server) StartReconciler(ctx context.Context, interval time.Duration)

StartReconciler launches a background loop that periodically syncs each server's stored lifecycle state with the authoritative state reported by its hosting Agent. This is what surfaces watchdog-driven transitions — a crash, an auto-restart, or a ready_regex flip from starting→running — in the UI without requiring an operator power action. It returns immediately; the loop runs until ctx is cancelled.

func (*Server) StartScheduler

func (s *Server) StartScheduler(ctx context.Context, interval time.Duration)

StartScheduler launches the background loop that runs due scheduled tasks (restart / backup / command). It ticks on `interval` (which should be well under the 1-minute cron granularity to avoid drift) and runs until ctx is cancelled.

func (*Server) StartTunnel added in v0.21.0

func (s *Server) StartTunnel(ctx context.Context)

StartTunnel runs the reverse-tunnel listener until ctx is canceled. No-op when the listener is disabled.

Jump to

Keyboard shortcuts

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