Documentation
¶
Index ¶
- Constants
- func IsLoopbackAddr(bind string) bool
- func LoadOrCreateToken(path string) (string, error)
- func NewMux(s *Server) http.Handler
- func NewRecorder(source capture.FrameSource, current holdSource, dir string) *recorder
- func RegisterMDNS(name string, port int, resolution string) (shutdown func(), err error)
- func TlsStatus(w io.Writer, certFile, keyFile string) error
- func TokenPath() (string, error)
- func WriteNewToken(path string) (string, error)
- type Auth
- type CertReloader
- type Server
- type SoundSource
- type StationLink
- type VideoTap
Constants ¶
const ( AuthUnset = "" AuthToken = "token" AuthTailscale = "tailscale" AuthNone = "none" )
Variables ¶
This section is empty.
Functions ¶
func IsLoopbackAddr ¶
isLoopbackAddr says whether a bind address only reaches this machine.
func LoadOrCreateToken ¶
loadOrCreateToken reads the token file, making a new token if there is none.
func NewRecorder ¶
func NewRecorder(source capture.FrameSource, current holdSource, dir string) *recorder
func RegisterMDNS ¶
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 TokenPath ¶
tokenPath is where the local admin token lives: a file only Roadie's user can read, next to the saved crops.
func WriteNewToken ¶
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.
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 ¶
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 ¶
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 ¶
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 ¶
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.