Documentation
¶
Overview ¶
Package server assembles the roles a mainplane-server process runs. Today that is one role, harness.
Index ¶
- Constants
- Variables
- func Auth(dir string) auth.Store
- func Harness(ctx context.Context, path string) error
- func Install(c *Config, keep bool) (string, error)
- func Key(dir string) (ed25519.PrivateKey, error)
- func SetTunnel(t *Tunnel) (string, error)
- func Uninstall() error
- func Up(path string) error
- func Update(v string) error
- type Config
- type Provider
- type Tunnel
Constants ¶
const (
Dir = worker.HarnessDir
)
Dir is the worker's constant: admin serves the sessions drive from it.
Variables ¶
var Conf = filepath.Join(Dir, "config.json")
Conf is the config the installed harness runs from.
Functions ¶
func Harness ¶
Harness runs the harness role on one loopback port, behind the user's own tunnel or a quick one, until ctx ends or the listener, the mesh node or the tunnel fails: /id proves the harness key to anyone before they send a secret, /ts2021 coordinates the mesh, /derp relays between its nodes, connectors call every other route with an api key, every session that was open on start resumes. The harness joins its own mesh, and workers dial it there. The pointer and the relay map follow the tunnel's URL. The config at path is read again when it changes: providers, links and drives apply at once.
func Install ¶
Install makes this machine run the harness at every boot, from a copy of an expanded c at Conf, or with keep from the config already there, as it is, which c becomes, makes it the worker admin while the tunnel starts, and returns the harness's URL once it answers there. Dir is root's and the operator's alone: the config holds the keys, and admin runs code as the operator so that it may read and edit them.
func Key ¶ added in v0.5.0
func Key(dir string) (ed25519.PrivateKey, error)
Key is the harness key every token carries, made on first use.
func SetTunnel ¶ added in v0.2.0
SetTunnel makes the installed harness reached through t, or through a quick tunnel when t is nil, restarts it, and returns its URL once it answers there. Workers follow through the pointer.
func Uninstall ¶ added in v0.1.1
func Uninstall() error
Uninstall stops the harness and removes its service and binary, and the worker admin. Dir stays: it holds the sessions.
Types ¶
type Config ¶
type Config struct {
HTTP string `json:"http"` // loopback address the tunnel carries connectors and workers to
Tunnel *Tunnel `json:"tunnel,omitempty"` // the user's own; none is a quick tunnel
Providers map[string]Provider `json:"providers"`
Links [][2]string `json:"links,omitempty"` // pairs of workers, by name, that reach each other on the mesh
Drives map[string]coordinator.Drive `json:"drives,omitempty"` // by name: each one's server and workers
}
Config is the self-hosted config file. Provider values are expanded from the environment, so a key can be "$ANTHROPIC_API_KEY". The directory it is in is the harness's: the harness key, the auth table, the mesh and the tunnel are there, and sessions in sessions/ under it, the one directory a drive may ever share.
func Default ¶ added in v0.1.1
func Default() Config
Default is the config install writes when given none and none is installed: the tunnel carries workers and connectors to port 8080 on loopback, and every provider whose key is set in this environment serves. With none set, keys go in the config after install.