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 ¶
- type Option
- type Server
- func (s *Server) AutoRegisterLocalNode(ctx context.Context)
- func (s *Server) Close() error
- func (s *Server) Handler() http.Handler
- func (s *Server) StartNodeReconciler(ctx context.Context, interval time.Duration)
- func (s *Server) StartReconciler(ctx context.Context, interval time.Duration)
- func (s *Server) StartScheduler(ctx context.Context, interval time.Duration)
- func (s *Server) StartTunnel(ctx context.Context)
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 ¶
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
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 ¶
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 ¶
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) StartNodeReconciler ¶ added in v0.13.0
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 ¶
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 ¶
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
StartTunnel runs the reverse-tunnel listener until ctx is canceled. No-op when the listener is disabled.
Source Files
¶
- audit.go
- handlers_agentupdate.go
- handlers_auth.go
- handlers_backups.go
- handlers_catalog.go
- handlers_database.go
- handlers_dns.go
- handlers_enroll.go
- handlers_files.go
- handlers_node.go
- handlers_nodeconfig.go
- handlers_schedule.go
- handlers_server.go
- handlers_settings.go
- handlers_setup.go
- handlers_sftp.go
- handlers_spec.go
- handlers_stream.go
- handlers_unifi.go
- handlers_user.go
- internal_gate.go
- json.go
- metrics.go
- middleware.go
- openapi.go
- reconcile.go
- rotate.go
- schedule.go
- server.go
- sftpproxy.go