Documentation
¶
Overview ¶
Package app wires configuration, storage, auth primitives and HTTP handlers into a runnable server, and implements the rdpanel command line.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type App ¶
type App struct {
Config *config.Config
Log *slog.Logger
DB *db.DB
Store *store.Store
AEAD *crypto.AEAD
JWT *auth.ClientJWT
Hasher *auth.Hasher
Limiter *auth.Backoff
Registry *prometheus.Registry
SPA *web.SPA
// WebFS is the built SPA (web/dist); /api/v1/docs serves api-docs.html and
// its assets from it.
WebFS fs.FS
// Events is the in-process pub/sub behind /api/v1/events.
Events *events.Bus
// EventsAuth authenticates SSE streams (panel sessions, set by the admin
// API wiring). nil denies every stream.
EventsAuth events.Authenticator
// HBBS is the hbbs/hbbr integration (presence, admin channel, reconciler).
HBBS HBBS
// Relays manages relays (local, static, agents), the computed hbbs relay
// list and the agent hub at /agent/v1/*.
Relays *relays.Service
// Federation manages peer panels and federated relays (nil unless
// RDPANEL_FEDERATION_ENABLED: no public endpoints, no sync loop).
Federation *federation.Service
// Kicks queues admin "disconnect" requests delivered by client heartbeats;
// shared by the client API (Take) and the admin API (Kick).
Kicks *clientapi.MemKickQueue
// WebSessions maps web client session ids to panel users (ACL checks).
WebSessions *websessions.Registry
// ClientOptions are pushed to clients in heartbeat strategies; shared by
// the client API (StrategyFor) and the admin API (/server/client-options).
ClientOptions *clientopts.Service
// TOTP verifies second factors; it implements clientapi's TOTPVerifier
// (Enrolled/Verify) for the client /api/login tfa step.
TOTP *adminapi.TOTPService
// Mail sends e-mail codes and password reset links (internal/mailauth).
Mail *mailauth.Service
// LDAP manages directory synchronization and corporate authentication (internal/ldap).
LDAP *ldap.Service
// Webhook dispatches alerts for critical events (internal/webhook).
Webhook *webhook.Service
// StartedAt is when New ran (About page uptime).
StartedAt time.Time
// Updates is the cached GitHub release check (nil when
// RDPANEL_UPDATE_CHECK=false).
Updates *updatecheck.Checker
// Clients looks up RustDesk releases for the "Install client" page (nil
// when client downloads are disabled).
Clients *clientdl.Service
// Telemetry holds the login / client-token / audit counters.
Telemetry *metrics.Panel
// Logs is the in-memory buffer behind Server -> Logs (never nil after New).
Logs *logs.Buffer
// contains filtered or unexported fields
}
App holds every long-lived dependency. There are no package-level singletons; handlers receive what they need through their package's Deps.
func New ¶
New opens the database (applying migrations), loads keys and builds the App. Call Close when done.
func (*App) Handler ¶
Handler builds the root HTTP handler:
/healthz, /metrics
/api/v1/admin/* panel API (stream B)
/api/v1/events SSE (stream C)
/api/v1/openapi.{yaml,json}, /api/v1/docs API contract + Swagger UI
/api/* RustDesk client API (stream A)
/agent/v1/* relay agent hub (enroll, WebSocket session)
/agent/install.sh relay agent installer (static script, no auth)
/s/* public server share pages (RDPANEL_SHARE_LINKS_ENABLED; 404 when off)
/internal/hbbs/authorize connection authorization for hbbs (loopback + secret)
/* embedded SPA
type HBBS ¶
type HBBS struct {
Presence *presence.Poller
Control *control.Client
Reconciler *reconcile.Reconciler
// RelayStats samples hbbr "usage" for the relay metrics.
RelayStats *relaystats.Poller
}
HBBS groups the hbbs/hbbr integration. Fields are nil when the integration is disabled (RDPANEL_HBBS_ENABLED=false); Control/Reconciler are also nil when the configured addresses are not loopback (the admin channel only accepts loopback peers).
type Option ¶ added in v0.3.0
type Option func(*App)
Option customises New.
func WithLogBuffer ¶ added in v0.3.0
WithLogBuffer makes the app serve Server -> Logs from b (created by the caller before the logger, so the panel's own startup lines are captured).