Documentation
¶
Index ¶
- Constants
- func NewRouter(options ...Option) http.Handler
- type Drain
- type Option
- func WithAdminAuth(service *auth.Service, security SecuritySettings, guests ...*access.Service) Option
- func WithConsole(service *auth.Service, security SecuritySettings, db *store.Store, ...) Option
- func WithRecordings(service *auth.Service, security SecuritySettings, ...) Option
- func WithSPA(files fs.FS, secureCookies bool) Option
- func WithTerminals(service *auth.Service, security SecuritySettings, manager *session.Manager, ...) Option
- type SecuritySettings
- type Setting
- type TerminalSettings
Constants ¶
const ( CloseSlowConsumer websocket.StatusCode = 4000 CloseReplayGap websocket.StatusCode = 4001 CloseInputOverflow websocket.StatusCode = 4004 )
Application close codes.
const TerminalProtocol = "webpty.terminal.v1"
TerminalProtocol is the WebSocket subprotocol clients must offer.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Drain ¶
type Drain struct {
// contains filtered or unexported fields
}
Drain tracks in-flight requests, including WebSocket handlers whose connections http.Server no longer tracks once hijacked, so shutdown can cancel them and wait before closing what they use.
type Option ¶
Option configures the router.
func WithAdminAuth ¶
func WithAdminAuth(service *auth.Service, security SecuritySettings, guests ...*access.Service) Option
WithAdminAuth mounts the administrator authentication API. When guests is given, signing out also revokes the browser's access session.
func WithConsole ¶
func WithConsole(service *auth.Service, security SecuritySettings, db *store.Store, settings []Setting) Option
WithConsole mounts the admin audit log and the read-only runtime settings.
func WithRecordings ¶
func WithRecordings(service *auth.Service, security SecuritySettings, recordings *recording.Service) Option
WithRecordings mounts the admin recording API: metadata, validated playback, asciicast export, deletion, and retention.
func WithSPA ¶
WithSPA serves the embedded single-page application for /, /admin, and /join. Vite's content-hashed /assets are cached immutably; the HTML shell is revalidated on every load. API routes are more specific and win. secureCookies also enables the HSTS response header on document loads.
func WithTerminals ¶
func WithTerminals(service *auth.Service, security SecuritySettings, manager *session.Manager, settings TerminalSettings) Option
WithTerminals mounts the admin terminal REST API and the terminal WebSocket, plus the capability-grant routes when settings.Access is set.
type SecuritySettings ¶
type SecuritySettings struct {
// PublicOrigin, when set, is the only origin accepted for mutating
// requests. Otherwise requests must target a loopback Host and mutating
// requests must originate from that same Host, which defeats DNS
// rebinding against local installations.
PublicOrigin string
SecureCookies bool
}
SecuritySettings control cookie and origin policy.
type Setting ¶
type Setting struct {
Key string `json:"key"`
Group string `json:"group"`
Label string `json:"label"`
Value string `json:"value"`
RestartRequired bool `json:"restartRequired"`
}
Setting is one sanitized runtime configuration value shown to the administrator. Values must never include credentials, tokens, or command arguments.
type TerminalSettings ¶
type TerminalSettings struct {
// WriteTimeout bounds each WebSocket message write.
WriteTimeout time.Duration
// PingInterval is how often the peer is probed and the admin session
// re-validated.
PingInterval time.Duration
// Heartbeat returns the ticks that drive each connection's heartbeat
// and a function that stops them. A time.Ticker is used when nil.
Heartbeat func(interval time.Duration) (<-chan time.Time, func())
// MaxMessageBytes limits one client WebSocket message.
MaxMessageBytes int64
// InputQueueBytes bounds input one connection may have waiting for the
// PTY. A client that exceeds it is closed with CloseInputOverflow. One
// message is always accepted into an empty queue, whatever its size.
InputQueueBytes int
// TerminateTimeout bounds how long DELETE waits for the process to exit.
TerminateTimeout time.Duration
// Access, when set, enables capability grants: the admin grant routes,
// guest redemption and sessions, and guest WebSocket connections.
Access *access.Service
// Presence tracks participants; a private hub is used when nil.
Presence *collab.Hub
// Recordings, when set, warns owners over the WebSocket when the
// terminal's recording stops early. Guests are never told.
Recordings *recording.Service
// RedeemThrottle limits invitation redemption attempts per client.
RedeemThrottle *auth.Throttle
Logger *slog.Logger
}
TerminalSettings tune the terminal transport. Zero fields receive defaults.