api

package
v1.0.24 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2026 License: MIT Imports: 22 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package api exposes the core over HTTP/JSON. Every request needs the API token, so a web page opened in the user's browser cannot drive the client through localhost.

Index

Constants

View Source
const OpenToken = "open"

OpenToken is the key of a server in open mode (see SetOpen). It is no secret: the pages carry it so that they send the Authorization header every request needs, which a page of another site cannot do without a preflight request that this server never allows.

Variables

This section is empty.

Functions

func LoadToken

func LoadToken(path string) (string, error)

LoadToken returns the persistent API token stored at path, creating it if needed.

Types

type About added in v1.0.1

type About struct {
	Name    string `json:"name"`
	Version string `json:"version"`
	GoVer   string `json:"goVersion"`
	OS      string `json:"os"`     // "windows/amd64"
	Engine  string `json:"engine"` // e.g. "github.com/anacrolix/torrent v1.61.0", "" if unknown
}

About is the static "About" info of the running build, for the settings page.

type Server

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

Server is the HTTP handler.

func New

func New(m *core.Manager, cfg *config.Store, token string, ui http.Handler) *Server

New builds the handler. ui serves the web interface for non-API paths (may be nil).

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Server) SetOpen added in v1.0.24

func (s *Server) SetOpen(extraHosts []string)

SetOpen puts the server in open mode, for running behind a proxy that signs the user in (Umbrel's app proxy does): nobody has to carry a personal key, every page gets OpenToken, and the host names of the requests need not be loopback ones. Because DNS rebinding needs a name, a request is still refused unless it comes by an IP address, a short or local name (see hostAllowed) or one of extraHosts.

type UpdateStatus added in v1.0.6

type UpdateStatus struct {
	Available bool   `json:"available"`
	Version   string `json:"version,omitempty"`
	Notes     string `json:"notes,omitempty"`
	URL       string `json:"url,omitempty"` // the release's page, for a manual download
}

UpdateStatus is what the settings page shows about a newer release.

Jump to

Keyboard shortcuts

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