web

package
v0.3.0-rc.55 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2026 License: Apache-2.0 Imports: 40 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 web serves the browser: the console (a React application under /workspace, which calls the REST API with its session, workspacefiles.go), and the pages that must work without it. Those are the public ones at the site's root (the status pages and their badges, or a page that names the deployment), the pages people open from the chat without an account (an alert's page with its timeline and the sessions on its machines, a session's page with its replay; view-only, with a signed link from package link or a bearer credential carrying the scope the matching API route needs), and the page where a person allows an MCP client (oauth.go). They are HTML from embedded templates on the design system @openlinkos/ui (vendored under static/ol), in the configured language, readable on a phone; every page says it runs on Beacon and links to the project (brand.go).

A wrong or expired link is a plain 404, so that it reveals nothing, not even that the page exists. A person signed in to the console opens the console's own page instead. Text from outside Beacon reaches the pages cleaned by the bridge and is escaped by html/template on the way out; the pages carry no inline script or style, and their Content-Security-Policy allows nothing from elsewhere.

Index

Constants

View Source
const CSP = "default-src 'none'; script-src 'self' 'wasm-unsafe-eval'; style-src 'self'; font-src 'self'; img-src 'self' data:; " +
	"connect-src 'self'; base-uri 'none'; form-action 'self'; frame-ancestors 'none'"

CSP is the pages' Content-Security-Policy: scripts, styles and fonts from Beacon itself only (the player's terminal runs as WebAssembly, hence wasm-unsafe-eval), no inline script or style, fetches and forms to Beacon only.

Variables

View Source
var BadgeKinds = []string{"status", "uptime", "uptime-30d", "response", "cert"}

BadgeKinds are the kinds of monitor badge.

View Source
var BadgeStyles = []string{"flat", "flat-square", "plastic", "for-the-badge"}

BadgeStyles are the styles a badge may be drawn in, the default first.

Functions

This section is empty.

Types

type MonitorFigures

type MonitorFigures struct {
	Name, Status         string
	Uptime24h, Uptime30d *float64
	LatencyMS            *float64
	CertDays             *int
}

MonitorFigures are what a monitor's badges show.

type Server

type Server struct {
	Bridge   *bridge.Bridge
	SSH      *sshgate.Gate
	Auth     *api.Auth
	Pages    *link.Pages
	Lang     i18n.Lang
	Location *time.Location
	Log      *slog.Logger
	Now      func() time.Time

	Store  *store.Store
	Config *configdb.Service
	Hooks  []config.Agent
	// MonitorFigures are a monitor's figures for its public badges (monitor_badges.go); nil: no badges.
	MonitorFigures func(id string) (MonitorFigures, bool)
	Version        string

	// Status computes the public status pages (status.go); nil leaves them out.
	Status   *status.Service
	Branding config.Branding

	// OAuth is Beacon's authorization server for MCP clients (package oauth); nil leaves /oauth/authorize out.
	OAuth *oauth.Server
	// contains filtered or unexported fields
}

Server serves the pages. SSH is nil when the channel is off (session pages are then 404); Auth checks bearer tokens (nil: only signed links open pages); Pages checks the links' signatures and signs the links inside pages (nil: only tokens open pages, and pages link nowhere).

The console needs Store, where its sign-ins are kept: nil leaves it out, and only the pages opened from the chat are served. Config is the configuration Beacon holds (the badges read it), Hooks the agent hooks configured, and Version Beacon's own. Branding is what the public pages say of the deployment and of Beacon.

func (*Server) APISession

func (s *Server) APISession(r *http.Request) (api.ConsoleSession, bool)

APISession is the request's console session: who its viewer is now, its CSRF secret and its end.

func (*Server) Console

func (s *Server) Console() bool

Console reports whether the console is served (it needs the store for its sign-ins).

func (*Server) Hosts

func (s *Server) Hosts(next http.Handler) http.Handler

Hosts serves a status page's own host name: the page at /, its incidents under /incidents/, its JSON, feed and badges, robots.txt and the static files the page needs; nothing else of Beacon, the console, the API and MCP included, answers there. Other hosts go to next.

func (*Server) Language

func (s *Server) Language(r *http.Request) i18n.Lang

Language is the language the console shows the request's browser.

func (*Server) Register

func (s *Server) Register(mux *http.ServeMux)

Register adds the pages' routes to mux: GET / is public (home.go), the console is under /workspace, the pages a link opens under /console, and the paths those had before they moved there send people on to their new place.

func (*Server) SetLanguage

func (s *Server) SetLanguage(w http.ResponseWriter, l i18n.Lang)

SetLanguage keeps the browser's choice of language for a year.

func (*Server) UpdateSettings

func (s *Server) UpdateSettings(lang i18n.Lang, loc *time.Location, hooks []config.Agent, branding config.Branding)

UpdateSettings updates the web server's live language, timezone, wake hooks and branding without restarting.

Directories

Path Synopsis
Package link signs requests for the alert and session pages people open from chat.
Package link signs requests for the alert and session pages people open from chat.

Jump to

Keyboard shortcuts

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