web

package
v0.0.0-...-0e5d3d6 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: MIT Imports: 55 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

Index

Constants

View Source
const (
	AuthUnset     = ""
	AuthToken     = "token"
	AuthTailscale = "tailscale"
	AuthNone      = "none"
)

Variables

This section is empty.

Functions

func IsLoopbackAddr

func IsLoopbackAddr(bind string) bool

isLoopbackAddr says whether a bind address only reaches this machine.

func LoadOrCreateToken

func LoadOrCreateToken(path string) (string, error)

loadOrCreateToken reads the token file, making a new token if there is none.

func NewMux

func NewMux(s *Server) http.Handler

NewMux wires up all HTTP routes and returns a handler.

func NewRecorder

func NewRecorder(source capture.FrameSource, current holdSource, dir string) *recorder

func RegisterMDNS

func RegisterMDNS(name string, port int, resolution string) (shutdown func(), err error)

RegisterMDNS advertises the Roadie service via Bonjour/mDNS and responds to A record queries for <name>.local so browsers can reach us by name. The service instance keeps the name as given, since that is a display name browsers never resolve; only the hostname is normalized. Returns a shutdown function to call on exit.

func TlsStatus

func TlsStatus(w io.Writer, certFile, keyFile string) error

tlsStatus describes a certificate file: `roadie tls status`.

func TokenPath

func TokenPath() (string, error)

tokenPath is where the local admin token lives: a file only Roadie's user can read, next to the saved crops.

func WriteNewToken

func WriteNewToken(path string) (string, error)

writeNewToken replaces the token file with a fresh token: the prefix and 32 random bytes in hex.

Types

type Auth

type Auth struct {
	Mode  string
	Allow []string // tailscale: logins and tags allowed; empty means any tailnet identity
	// Loopback says Roadie listens on localhost only, which is when the
	// Tailscale-User-Login header from tailscale serve can be trusted.
	Loopback bool
	// Secure says pages are served over TLS, so cookies are marked Secure.
	Secure bool
	// contains filtered or unexported fields
}

Auth checks every request against the chosen mode.

func NewAuth

func NewAuth(mode, allow string) (*Auth, error)

NewAuth sets up the mode, creating the local token on first use.

func (*Auth) Wrap

func (a *Auth) Wrap(next http.Handler) http.Handler

Wrap checks every request but the login pages.

type CertReloader

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

certReloader serves a certificate and key from files and picks up new ones when the files change, so a renewal needs no restart.

func NewCertReloader

func NewCertReloader(certFile, keyFile string) (*CertReloader, error)

func (*CertReloader) GetCertificate

func (r *CertReloader) GetCertificate(*tls.ClientHelloInfo) (*tls.Certificate, error)

GetCertificate is for tls.Config.

func (*CertReloader) Leaf

func (r *CertReloader) Leaf() *x509.Certificate

Leaf is the certificate being served.

type Server

type Server struct {
	Source         capture.FrameSource
	Buf            *capture.FrameBuffer
	RelayFPS       int // frame rate cap for the MJPEG stream through a station
	Device         string
	AudioBroadcast *audio.AudioBroadcaster
	// AudioSource says which of the phone's outputs /audio is following,
	// "usb" or "hdmi", when there is a choice (the gadget backend); nil
	// otherwise.
	AudioSource func() string
	SourceType  string // "hardware" or "http"
	HID         hid.HIDBackend
	Capture     *capture.CaptureManager
	// DefaultFPS is --fps: what the capture goes back to when the frame
	// rate is set to Auto. Zero leaves the capture's rate alone.
	DefaultFPS int

	// RTC sends the picture over WebRTC; nil when this host has no way to
	// encode H.264 or frames come from an HTTP source.
	RTC *rtc.Broadcaster
	// Station is the rig side, while enrolled with one: see station.go.
	Station StationLink // the rig's link to its stations, when it has one
	// GesturePage and SoundcheckPage are the e2e test pages under board/,
	// embedded by the main package and served at /gestures and /soundcheck.
	GesturePage, SoundcheckPage []byte
	// Auth decides who may use the pages and API; see --auth.
	Auth *Auth

	// InputMode is the pointer mode this target wants — "mouse", "touch", or
	// empty to leave the choice to the viewer. It belongs to the server
	// because it is a property of the device on the other end of the cable,
	// which the browser has no way to know.
	InputMode string

	// Platform is the target's OS, which decides how it reads absolute
	// pointer coordinates and what input mode suits it. Empty means
	// unspecified.
	Platform platform.Platform

	// Name is this instance's --name. It labels the browser tab so that
	// several targets open at once stay tellable apart.
	Name string

	// Label is the device's name for people on a station, --label; empty
	// leaves the station to show the device by its model or its kind.
	Label string

	// Model and OSVersion are --model and --os-version: what the device
	// is and what it runs, told to the station and to agents.
	Model     string
	OSVersion string

	// CropFile is where saved crops are kept between runs; empty keeps
	// them only until roadie stops.
	CropFile string
	// contains filtered or unexported fields
}

func (*Server) EffectiveInputMode

func (s *Server) EffectiveInputMode() string

effectiveInputMode is the mode viewers actually start in: --input when given, otherwise whatever the platform implies. Reported by /health so the answer is visible rather than inferred from two flags.

func (*Server) HidCommand

func (s *Server) HidCommand(ctx context.Context, data []byte)

HidCommand runs one input command from a viewer, the JSON /api/hid/ws takes, as the "hid" data channel of a WebRTC session carries it. ctx ends with the session.

func (*Server) PointerTurned

func (s *Server) PointerTurned() bool

pointerTurned reports whether the pointer has to be turned to land where it is aimed. An iPhone reads an absolute pointer the way it believes it is held. An app that turned with it faces that way too, but one that can't turn (the home screen, Settings) stays upright, and there every tap lands a quarter turn away until the phone is turned upright again.

type SoundSource

type SoundSource interface {
	Subscribe() (<-chan []byte, func())
	Params() audio.AudioParams
	IsActive() bool
}

SoundSource is the device's sound. audio.AudioBroadcaster is one.

type StationLink interface {
	Status() map[string]any
}

Server holds the state needed by HTTP handlers. StationLink is what the server asks of the rig's link to its stations: what to show about them on /health and the index page.

type VideoTap

type VideoTap interface {
	Available() bool
	Tap(sink rtc.SampleSink) (stop func())
	// ViewerRecording says a viewer is keeping the stream itself.
	ViewerRecording() bool
}

VideoTap is where the encoded picture comes from. rtc.Broadcaster is one.

Jump to

Keyboard shortcuts

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