web

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: MIT Imports: 25 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 is hamstack's browser dashboard: the services and their state, controls, links to the programs' own web UIs, and desktop programs or the whole desktop in the browser through noVNC. The dashboard is the only way in: the VNC servers listen on localhost, and the dashboard relays a browser's WebSocket to them only after a login.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckPassword

func CheckPassword(hash, pw string) bool

CheckPassword reports whether pw matches a hash made by HashPassword.

func HashPassword

func HashPassword(pw string) (string, error)

HashPassword returns "pbkdf2-sha256$ITERATIONS$SALT$KEY" (salt and key in base64).

func SavePasswordHash

func SavePasswordHash(file, hash string) error

SavePasswordHash writes the hash to file, readable by its owner only.

Types

type App

type App struct {
	Name      string `json:"name"`
	Title     string `json:"title"`
	Package   string `json:"package"`
	Installed bool   `json:"installed"`
	Running   bool   `json:"running"`
	Radio     bool   `json:"radio"` // uses the radio's sound card
}

App is one desktop program the dashboard can open in the browser.

type Backend

type Backend interface {
	State() State
	Control(service, verb string) error // verb: start, stop, restart
	OpenApp(name string) error          // start the program on its display (stopping the HF modem first if it needs the radio)
	CloseApp(name string) error
	OpenDesktop() error
	CloseDesktop() error
	Target(name string) (port int, ok bool) // the localhost VNC port of a running program, or of "desktop"
}

Backend is what the dashboard needs from hamstack.

type ManagementBackend

type ManagementBackend interface {
	ManagementState() any
	Manage(ManagementRequest) (any, error)
}

type ManagementRequest

type ManagementRequest struct {
	Action  string `json:"action"`
	ID      string `json:"id"`
	Value   string `json:"value"`
	Extra   string `json:"extra"`
	Confirm bool   `json:"confirm"`
}

type Options

type Options struct {
	Addr         string // ":443"
	CertFile     string
	KeyFile      string
	PasswordFile string
	NoVNCPath    func() string // dynamically resolve assets after installing them
	NoVNCDir     string        // noVNC's web files; "" if noVNC is not installed
	Logf         func(format string, args ...any)
}

Options configure the server.

type RemoteCheck

type RemoteCheck struct {
	Name   string `json:"name"`
	Ready  bool   `json:"ready"`
	Detail string `json:"detail"`
}

type Server

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

Server is the dashboard.

func New

func New(be Backend, o Options) *Server

New makes a dashboard server.

func (*Server) Handler

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

Handler is the dashboard's HTTP handler.

func (*Server) ListenAndServe

func (s *Server) ListenAndServe() error

ListenAndServe serves the dashboard over HTTPS. A renewed certificate is picked up on the next connection, with no restart.

type Service

type Service struct {
	Name     string `json:"name"`  // "rigctld@hf", "pat"
	What     string `json:"what"`  // "rig control"
	State    string `json:"state"` // "running", "stopped", "failed", "no radio", "starting", "not installed"
	Since    string `json:"since,omitempty"`
	Enabled  bool   `json:"enabled"`            // starts at login/boot
	Control  bool   `json:"control"`            // the dashboard may start and stop it
	LinkPort int    `json:"linkPort,omitempty"` // its own web UI, on this computer, if any
	Scheme   string `json:"scheme,omitempty"`   // "http" or "https"
	Note     string `json:"note,omitempty"`     // for instance "web UI on this computer only"
}

Service is one row of the services table.

type State

type State struct {
	BrowserReady   bool             `json:"browserReady"`
	Updates        updates.Snapshot `json:"updates"`
	Pending        []string         `json:"pending"`
	Notices        []string         `json:"notices"`
	Reboot         bool             `json:"reboot"`
	RemoteChecks   []RemoteCheck    `json:"remoteChecks"`
	DesktopNote    string           `json:"desktopNote"`
	Station        string           `json:"station"`
	Site           string           `json:"site"`
	Grid           string           `json:"grid"`
	RadioUser      string           `json:"radioUser,omitempty"` // the program that has the radio's sound card now
	Services       []Service        `json:"services"`
	Apps           []App            `json:"apps"`
	Desktop        bool             `json:"desktop"` // the computer's desktop can be shared
	DesktopRunning bool             `json:"desktopRunning"`
}

State is what the dashboard shows.

Jump to

Keyboard shortcuts

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