api

package
v2.11.0 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2026 License: GPL-3.0 Imports: 52 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var JSONRPCErrorInternalError = models.ErrorObject{
	Code:    -32603,
	Message: "Internal error",
}
View Source
var JSONRPCErrorInvalidParams = models.ErrorObject{
	Code:    -32602,
	Message: "Invalid params",
}
View Source
var JSONRPCErrorInvalidRequest = models.ErrorObject{
	Code:    -32600,
	Message: "Invalid Request",
}
View Source
var JSONRPCErrorMethodNotFound = models.ErrorObject{
	Code:    -32601,
	Message: "Method not found",
}
View Source
var JSONRPCErrorParseError = models.ErrorObject{
	Code:    -32700,
	Message: "Parse error",
}

Functions

func Start

func Start(
	platform platforms.Platform,
	cfg *config.Instance,
	st *state.State,
	inTokenQueue chan<- tokens.Token,
	confirmQueue chan<- chan error,
	db *database.Database,
	limitsManager *playtime.LimitsManager,
	notifBroker *broker.Broker,
	mdnsHostname string,
	player audio.Player,
	indexPauser *syncutil.Pauser,
) error

Start starts the API web server and blocks until it shuts down.

func StartWithReady added in v2.11.0

func StartWithReady(
	platform platforms.Platform,
	cfg *config.Instance,
	st *state.State,
	inTokenQueue chan<- tokens.Token,
	confirmQueue chan<- chan error,
	db *database.Database,
	limitsManager *playtime.LimitsManager,
	notifBroker *broker.Broker,
	mdnsHostname string,
	player audio.Player,
	indexPauser *syncutil.Pauser,
	ready chan<- error,
) error

StartWithReady starts the API web server and reports bind success or failure before blocking for shutdown. This lets service startup fail synchronously when the configured API port is unavailable.

Types

type MethodMap

type MethodMap struct {
	sync.Map
}

func NewMethodMap

func NewMethodMap() *MethodMap

func (*MethodMap) AddMethod

func (m *MethodMap) AddMethod(
	name string,
	handler func(requests.RequestEnv) (any, error),
) error

func (*MethodMap) GetMethod

func (m *MethodMap) GetMethod(name string) (func(requests.RequestEnv) (any, error), bool)

func (*MethodMap) ListMethods

func (m *MethodMap) ListMethods() []string

func (*MethodMap) Load

func (m *MethodMap) Load(key any) (any, bool)

func (*MethodMap) Range

func (m *MethodMap) Range(f func(key, value any) bool)

func (*MethodMap) Store

func (m *MethodMap) Store(key, value any)

type OriginsProvider added in v2.9.0

type OriginsProvider func() []string

OriginsProvider is a function that returns custom origins from config.

type PairingManager added in v2.11.0

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

PairingManager owns the PIN and in-flight sessions (single mutex protects all state).

func NewPairingManager added in v2.11.0

func NewPairingManager(
	db database.UserDBI,
	notifChan chan<- models.Notification,
	opts ...PairingOption,
) *PairingManager

NewPairingManager constructs a PairingManager (pass nil notifChan to disable notifications).

func (*PairingManager) CancelPairing added in v2.11.0

func (m *PairingManager) CancelPairing()

CancelPairing clears the current PIN and any in-flight sessions. Safe to call when no pairing is in progress.

func (*PairingManager) HandlePairFinish added in v2.11.0

func (m *PairingManager) HandlePairFinish() http.HandlerFunc

HandlePairFinish verifies HMAC, persists client, and returns auth token + confirmation.

func (*PairingManager) HandlePairStart added in v2.11.0

func (m *PairingManager) HandlePairStart() http.HandlerFunc

HandlePairStart runs the PAKE exchange and returns sessionID + server message.

func (*PairingManager) PendingPIN added in v2.11.0

func (m *PairingManager) PendingPIN() (pin string, expiresAt time.Time)

PendingPIN returns the currently displayed PIN and its expiry, or an empty PIN if no pairing is in progress.

func (*PairingManager) StartCleanup added in v2.11.0

func (m *PairingManager) StartCleanup(ctx context.Context)

StartCleanup begins the background cleanup goroutine. The goroutine exits when ctx is canceled. Safe to call multiple times only with distinct contexts; callers should call this once during server startup.

func (*PairingManager) StartPairing added in v2.11.0

func (m *PairingManager) StartPairing() (pin string, expiresAt time.Time, err error)

StartPairing generates a new PIN (fails fast if clients are at max).

type PairingOption added in v2.11.0

type PairingOption func(*PairingManager)

PairingOption configures a PairingManager at construction time.

func WithPairingCleanupInterval added in v2.11.0

func WithPairingCleanupInterval(d time.Duration) PairingOption

WithPairingCleanupInterval overrides the cleanup goroutine tick interval.

func WithPairingMaxAttempts added in v2.11.0

func WithPairingMaxAttempts(n int) PairingOption

WithPairingMaxAttempts overrides the maximum PIN attempts (default 3).

func WithPairingMaxClients added in v2.11.0

func WithPairingMaxClients(n int) PairingOption

WithPairingMaxClients overrides the maximum paired clients (default 50).

func WithPairingPINTTL added in v2.11.0

func WithPairingPINTTL(d time.Duration) PairingOption

WithPairingPINTTL overrides the PIN time-to-live (default 5min).

func WithPairingSessionTTL added in v2.11.0

func WithPairingSessionTTL(d time.Duration) PairingOption

WithPairingSessionTTL overrides the /pair/start session TTL (default 2min).

type PairingResult added in v2.11.0

type PairingResult struct {
	Client     *database.Client
	ServerHMAC []byte
}

PairingResult is the outcome of a successful PAKE handshake. The Client is persisted to the database; the ServerHMAC must be returned to the client so it can verify the server's identity.

Directories

Path Synopsis
Package crypto provides AES-256-GCM encryption with HKDF-derived per-session keys for the Zaparoo API WebSocket transport.
Package crypto provides AES-256-GCM encryption with HKDF-derived per-session keys for the Zaparoo API WebSocket transport.
Package validation provides validation for API request parameters using go-playground/validator with custom validators for Zaparoo-specific types.
Package validation provides validation for API request parameters using go-playground/validator with custom validators for Zaparoo-specific types.

Jump to

Keyboard shortcuts

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