server

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Overview

Package server runs an Aboard server: it opens the database, prepares the server's identity and, in local mode, its owner, then serves the API until the context ends.

Index

Constants

View Source
const AdminKeyFile = "admin-key"

AdminKeyFile is the file in a team server's data folder that the first admin's key is written to.

View Source
const DefaultLocalAddr = "127.0.0.1:7400"

DefaultLocalAddr is where the local server listens unless told otherwise.

Variables

This section is empty.

Functions

func JoinHost

func JoinHost(addr string) string

JoinHost is how join lines name a local server at addr: "localhost", with the port when it isn't the default.

func Run

func Run(ctx context.Context, o Options) error

Run serves a local server, or a team server with o.Team, until ctx is done, then shuts down gracefully.

Types

type Options

type Options struct {
	// Addr is the address to listen on, such as 127.0.0.1:7400.
	Addr string
	// Listener, when set, is the listener to serve on in place of Addr. Run closes it.
	// A caller that needs a free port listens on port 0 and passes the listener, since a
	// port closed again before Run listens can be taken in between.
	Listener net.Listener
	// DataDir holds aboard.db, server.pid and server.log.
	DataDir string
	// OwnerName is the local owner's login name, normalized into a member name.
	OwnerName string
	// MachineName names the owner's first access key, normalized like a member name.
	MachineName string
	// OwnerTokenPath is where local mode writes the owner's token (mode 0600) the first
	// time it starts.
	OwnerTokenPath string
	Version        string
	// Commit and CommitTime name the Git commit the server was built from, when known.
	Commit     string
	CommitTime time.Time
	Log        *slog.Logger
	Clock      clock.Clock
	Rand       io.Reader
	// Team, when set, runs a team server instead of the local one: OwnerName,
	// MachineName and OwnerTokenPath are then unused.
	Team *Team
}

Options configures a server.

type PublicURL

type PublicURL struct {
	// Origin is the URL's scheme, host and port: https://team.example.com.
	Origin string
	// Host is the Host header requests arrive with, with the port when it isn't 443.
	Host string
}

PublicURL is a team server's public address.

func ParsePublicURL

func ParsePublicURL(s string) (PublicURL, error)

ParsePublicURL checks a team server's public URL: https, a host, a port from 1 to 65535 if any, and no user, path (not even /), query or fragment. The default port is dropped, as browsers drop it from Origin and Host.

type Team

type Team struct {
	// PublicURL is the address people use, as ParsePublicURL returns it.
	PublicURL PublicURL
	// AdminName is the first admin's handle, made on the first start of an empty
	// database.
	AdminName string
}

Team configures a team server, which runs behind a proxy that ends HTTPS.

Jump to

Keyboard shortcuts

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