api

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: AGPL-3.0 Imports: 30 Imported by: 0

Documentation

Overview

Package api is WittyCouch's own HTTP API (module API 5): the routes WittyMediaServer passes to it at /api/modules/wittycouch/... once it has checked that someone is signed in (integration.json), the sources of its SDUI pages, and its lifecycle. It keeps each person's PCs in WittyCouch's own database (package store) and their keys and the PCs' pictures in its own folder, and asks the server only what only the server knows, through the host API: its settings, where the WittyCouch Host program is, and when an account goes.

This makes the server connect where a person says, which needs care:

  • The connections only speak this one protocol, on its own ports, to fixed paths. Answers are parsed into a few fields, and nothing a far end says is passed back raw, so this can't be used to read other services or as a general network probe.
  • What was refused and what timed out read the same to anyone but an admin, as the difference is what a port scanner wants.
  • Attempts are limited per person, and nobody but an admin reaches this machine itself.
  • Each person's certificate and pairings are their own, kept apart, and never shown.
  • Who may use it, and which networks it may reach, are an admin's settings.

Index

Constants

View Source
const DataEnv = "WITTYMODULE_DATA"

DataEnv is where the server says WittyCouch's own folder is.

View Source
const HeaderLimited = "X-Witty-Limited"

HeaderLimited is "1" on a request from a profile with limits set (age, libraries, screen time).

Variables

This section is empty.

Functions

func Busy

func Busy() bool

Busy says a stream is running (service.Config.Busy), so the service isn't stopped for being idle.

func Lifecycle

func Lifecycle(ctx context.Context, call string, args wittymodule.LifecycleArgs) error

Lifecycle answers the lifecycle calls integration.json says WittyCouch answers: taken off without keeping its data, its folder (database, keys, pictures) goes.

func Routes

func Routes(mux *http.ServeMux)

Routes adds the routes to a service's mux (service.Config.HTTP).

func SDUIItems

func SDUIItems(req sdui.ItemsRequest) (sdui.ItemsAnswer, error)

SDUIItems answers the server's sdui.items call for WittyCouch's sources.

func Stop

func Stop()

Stop ends every stream and pairing: the server is going away (service.Config.OnStop).

func Use

func Use(a *App)

Use makes a the App the routes use, for tests.

func Watch

func Watch()

Watch follows the server's events while the service runs: an account that goes takes its streams, PCs, key and pictures with it.

Types

type App

type App struct {
	DB   *store.DB
	Dir  string
	Host *host.Client
	Log  *slog.Logger
	// contains filtered or unexported fields
}

App is what the routes need: WittyCouch's database and folder, the way back to the server, and what's in memory: identities, pairings, streams.

func Get

func Get() (*App, error)

Get opens WittyCouch's database and reaches the server the first time something needs them.

func NewApp

func NewApp(db *store.DB, dir string, h *host.Client) *App

NewApp is an App over a database, a folder and a host API client.

func (*App) Forget

func (a *App) Forget(u int64)

Forget ends an account's streams and removes what it kept here.

Jump to

Keyboard shortcuts

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