config

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: Apache-2.0 Imports: 25 Imported by: ? 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 config persists Planck host and client settings as JSON in the user's config directory, and manages the host's TLS identity and the client's pinned host certificates.

Index

Constants

View Source
const (
	HostConfigFile   = "host.json"
	ClientConfigFile = "client.json"
)
View Source
const (
	DefaultDiscoveryPort = 41000
	DefaultControlPort   = 41001
	DefaultMediaPort     = 41002
)

The host's default ports, the first discovery.DefaultPort. They sit below 44620-48715, which WSL's mirrored networking reserves on the Windows host for both TCP and UDP, hidden from netstat and from excludedportrange, and below Windows' dynamic ports from 49152.

View Source
const (
	ClipboardBoth         = "both"
	ClipboardHostToClient = "host-to-client"
	ClipboardClientToHost = "client-to-host"
	ClipboardOff          = "off"
)

Clipboard directions a host allows, as HostConfig.Clipboard holds them.

View Source
const (
	MinStreamWindows     = 2
	MaxStreamWindows     = 4
	DefaultStreamWindows = 2
)

The bounds and default of ClientConfig.StreamWindows.

View Source
const (
	VirtualPadXbox360   = "xbox360"
	VirtualPadDS4       = "ds4"
	VirtualPadDualSense = "dualsense"
)

Virtual controller types a host can plug in, as GamepadConfig.VirtualType holds them.

View Source
const (
	MaxGamepadDeadzone         = 50
	MaxGamepadTriggerThreshold = 50
	MaxGamepadRumbleStrength   = 100
)

Limits of the GamepadConfig percentages.

View Source
const GamepadConfigFile = "gamepad.json"

GamepadConfigFile holds the gamepad settings of both roles, beside host.json and client.json; its own file keeps HostConfig comparable.

View Source
const MaxIdleTimeoutMinutes = 24 * 60

MaxIdleTimeoutMinutes is the longest IdleTimeoutMinutes, a day.

View Source
const VirtualMicOff = "off"

VirtualMicOff is HostConfig.VirtualMic for no microphone.

Variables

View Source
var (
	ErrUnknownHotkey = errors.New("config: no such hotkey")
	ErrNoModifier    = errors.New("needs at least one modifier")
	ErrReservedChord = errors.New("the system keeps this chord")
	ErrChordInUse    = errors.New("already in use")
	ErrNotGlobal     = errors.New("the desktop cannot take this chord while Planck is not in front")
	// ErrDesktopRefused is a host hotkey's chord the desktop would not
	// register while hosting, most often because another app holds it.
	ErrDesktopRefused = errors.New("the desktop refused this chord")
)

Why SetHotkey or AddNeverSend refused a chord; a *HotkeyError wraps one.

View Source
var (
	ErrUnknownHost         = errors.New("config: host is not paired")
	ErrFingerprintMismatch = errors.New("config: host certificate does not match the pinned fingerprint")
)
View Source
var ErrBadChord = errors.New("config: not a chord")

ErrBadChord is text ParseChord cannot read.

View Source
var HotkeyDefs = []HotkeyDef{
	{Action: HotkeyStreamMenu, Default: mustChord("Ctrl+Alt+O")},
	{Action: HotkeyHideButton, Default: mustChord("Ctrl+Alt+P")},
	{Action: HotkeyMetrics, Default: mustChord("Ctrl+Alt+M")},
	{Action: HotkeyCycleHUD, Default: mustChord("Ctrl+Alt+H")},
	{Action: HotkeyMicrophone, Default: mustChord("Ctrl+Alt+U")},
	{Action: HotkeyFullscreen, Default: mustChord("Ctrl+Alt+F")},
	{Action: HotkeyImmersive, Default: mustChord("Ctrl+Alt+I")},
	{Action: HotkeyCursorLock, Default: mustChord("Ctrl+Alt+G")},
	{Action: HotkeySwitchDisplay, Default: mustChord("Ctrl+Alt+]")},
	{Action: HotkeyCtrlAltDel, Default: mustChord("Ctrl+Alt+Backspace")},
	{Action: HotkeyKeyframe, Default: mustChord("Ctrl+Alt+K")},
	{Action: HotkeyDisconnect, Default: mustChord("Ctrl+Alt+Shift+D")},
	{Action: HotkeyStopHosting, Default: mustChord("Ctrl+F3"), Global: true},
	{Action: HotkeyKickClient, Global: true},
}

HotkeyDefs are every hotkey, in the order Settings lists them. The stream's keep to Ctrl+Alt so that the Cmd and Windows keys reach the host.

Functions

func CertFingerprint

func CertFingerprint(der []byte) string

CertFingerprint is the lowercase hex SHA-256 of a DER certificate.

func Dir

func Dir() (string, error)

Dir is the directory that holds Planck's config files: <user config dir>/planck.

func Hostname

func Hostname() string

Hostname is this machine's name as its owner knows it: the Computer Name of macOS Sharing settings, the computer name on Windows (os.Hostname reads GetComputerNameExW(ComputerNamePhysicalDnsHostname) there), and the host name elsewhere.

func LoadOrCreateIdentity

func LoadOrCreateIdentity(certPath, keyPath, commonName string) (tls.Certificate, error)

LoadOrCreateIdentity loads the host's ECDSA P-256 certificate and key, or creates a self-signed pair when neither file exists. It refuses to replace a lone cert or key, since that would silently change the pinned identity.

func ReservedChord

func ReservedChord(ch Chord, goos string) string

ReservedChord is why the system on goos keeps ch for itself, "" when it does not. Windows keeps every chord with the Windows key.

func SaveClientConfig

func SaveClientConfig(dir string, cfg ClientConfig) error

func SaveGamepadConfig

func SaveGamepadConfig(dir string, cfg GamepadConfig) error

func SaveHostConfig

func SaveHostConfig(dir string, cfg HostConfig) error

func TelemetryOn

func TelemetryOn(dir string) bool

TelemetryOn is client.json's TelemetryOn in dir, on when the file is missing and off when it cannot be read.

func UpdateClientConfig

func UpdateClientConfig(dir string, fn func(*ClientConfig) error) error

UpdateClientConfig loads <dir>/client.json, applies fn and saves the result.

func UpdateGamepadConfig

func UpdateGamepadConfig(dir string, fn func(*GamepadConfig) error) error

UpdateGamepadConfig loads <dir>/gamepad.json, applies fn and saves the result.

func UpdateHostConfig

func UpdateHostConfig(dir string, fn func(*HostConfig) error) error

UpdateHostConfig loads <dir>/host.json, applies fn and saves the result.

func VerifyPinnedCert

func VerifyPinnedCert(fingerprint string) func(rawCerts [][]byte, _ [][]*x509.Certificate) error

VerifyPinnedCert returns a tls.Config.VerifyPeerCertificate callback that accepts only a leaf certificate with the given fingerprint. Use it with InsecureSkipVerify, which only turns off CA and hostname checks.

Types

type AppList

type AppList string

AppList is a list of app names. It is a string inside so that HostConfig stays comparable; in JSON it is an array.

func NewAppList

func NewAppList(names ...string) AppList

NewAppList keeps the names that are not blank, once each, trimmed.

func (AppList) MarshalJSON

func (l AppList) MarshalJSON() ([]byte, error)

func (AppList) Names

func (l AppList) Names() []string

Names are the apps in the list.

func (*AppList) UnmarshalJSON

func (l *AppList) UnmarshalJSON(b []byte) error
type CalibratedLink struct {
	RTTP50Micros  int `json:"rttP50Micros"`
	RTTP99Micros  int `json:"rttP99Micros"`
	JitterMicros  int `json:"jitterMicros"`
	BandwidthMbps int `json:"bandwidthMbps"`
	DatagramBytes int `json:"datagramBytes"`
}

CalibratedLink is the route as calibration measured it.

type CalibratedRoute added in v0.2.0

type CalibratedRoute struct {
	At time.Time `json:"at"`
	// Overrides are the knobs calibration settled; ResolveOverrides puts
	// the user's own on top.
	Overrides defaults.UserOverrides `json:"overrides"`
	// ReceiveQueue is this client's receive queue on the route, which the
	// host paces video into; Bytes 0 found no limit.
	ReceiveQueue defaults.ReceiveQueue `json:"receiveQueue"`
	Link         CalibratedLink        `json:"link"`
	// GlassMs is the capture-to-glass p50 calibration measured for its
	// pick; 0 is unknown, as when its display phase did not run.
	GlassMs  float64  `json:"glassMs,omitempty"`
	Warnings []string `json:"warnings,omitempty"`
}

CalibratedRoute is what calibration measured on one route to a pinned host, and the stream settings it picked there.

func (CalibratedRoute) ResolveOverrides added in v0.2.0

func (r CalibratedRoute) ResolveOverrides(user defaults.UserOverrides) defaults.UserOverrides

ResolveOverrides is what a stream on the route asks for: calibration's knobs where user leaves them auto, user's everywhere else.

func (CalibratedRoute) Route added in v0.2.0

Route is base with what calibration measured of the route.

type Chord

type Chord struct {
	Mods Mods
	// Key is a HID usage that input.KeyName names.
	Key uint16
}

Chord is a key with the modifiers held for it. The zero Chord is no key: an unbound hotkey.

func ParseChord

func ParseChord(s string) (Chord, error)

ParseChord reads a chord as "Ctrl+Alt+K": modifiers, in any order and case, then one key by its input.KeyName name. Cmd, Win and Meta are Super; Option is Alt. "" is the zero Chord.

func (Chord) IsZero

func (c Chord) IsZero() bool

func (Chord) String

func (c Chord) String() string

String writes c as ParseChord reads it: "Ctrl+Alt+Shift+Super+K", the modifiers in that order, and "" for the zero Chord.

type ClientConfig

type ClientConfig struct {
	PreferredCodec  string `json:"preferredCodec"`
	PreferredChroma string `json:"preferredChroma"`
	TargetFPS       int    `json:"targetFPS"`
	MaxBitrateKbps  int    `json:"maxBitrateKbps"`
	AudioEnabled    bool   `json:"audioEnabled"`
	// ClipboardSend shares this device's clipboard with the other end of
	// a stream, and ClipboardReceive applies the other end's here. Both
	// start off.
	ClipboardSend    bool `json:"clipboardSend"`
	ClipboardReceive bool `json:"clipboardReceive"`
	// SystemKeysCapture is immersive mode: the stream takes the shortcuts
	// the client's own OS acts on, such as Cmd-Tab and the Windows key.
	SystemKeysCapture bool                  `json:"systemKeysCapture,omitempty"`
	ThemeName         string                `json:"themeName"`
	PinnedHosts       map[string]PinnedHost `json:"pinnedHosts"`
	// DeviceName is the name hosts pair this client under; empty is
	// Hostname().
	DeviceName string `json:"deviceName,omitempty"`
	// HostAliases are names the user gave hosts on this client, by host
	// ID; they replace the name the host advertises.
	HostAliases map[string]string `json:"hostAliases,omitempty"`

	Overrides     defaults.UserOverrides            `json:"overrides"`
	HostOverrides map[string]defaults.UserOverrides `json:"hostOverrides,omitempty"` // key: HostID

	// AudioVolume is the stream's playback level from 0 to 1; nil is
	// full.
	AudioVolume *float64 `json:"audioVolume,omitempty"`
	AudioMuted  bool     `json:"audioMuted,omitempty"`
	// Overlay is where the stream overlay was left; nil before the first
	// stream.
	Overlay *OverlayLayout `json:"overlay,omitempty"`
	// OpenFullscreen is whether a stream's window opens in full screen;
	// nil is on (StreamsOpenFullscreen).
	OpenFullscreen *bool `json:"openFullscreen,omitempty"`
	// OpenEveryHostDisplay opens a window for each host display, at most
	// StreamWindows of them, where the host streams several at once.
	OpenEveryHostDisplay bool `json:"openEveryHostDisplay,omitempty"`
	// MaxStreamWindows is StreamWindows as set; 0 is the default.
	MaxStreamWindows int `json:"maxStreamWindows,omitempty"`

	// Hotkeys are the hotkeys the user changed, by HotkeyAction, as
	// chords; "" is unbound. The rest keep their defaults (Hotkey).
	Hotkeys map[string]string `json:"hotkeys,omitempty"`
	// NeverSend are chords never sent to the host, such as a voice chat's
	// push-to-talk key.
	NeverSend []string `json:"neverSend,omitempty"`
	// SwapCmdCtrl trades Cmd and Ctrl in what goes to a host whose OS is
	// macOS when this one's is not, or the other way.
	SwapCmdCtrl bool `json:"swapCmdCtrl,omitempty"`
	// AudioOutputDevice and MicDevice are the devices a stream plays on
	// and records from, by audio.Device ID; empty, or a device that is
	// gone, is the system's default.
	AudioOutputDevice string `json:"audioOutputDevice,omitempty"`
	MicDevice         string `json:"micDevice,omitempty"`
	// TelemetryEnabled is anonymous usage telemetry, for the app and for
	// planck-host on this machine; nil is on (TelemetryOn).
	TelemetryEnabled *bool `json:"telemetryEnabled,omitempty"`
}

func DefaultClientConfig

func DefaultClientConfig() ClientConfig

func LoadClientConfig

func LoadClientConfig(dir string) (ClientConfig, error)

LoadClientConfig reads <dir>/client.json, or returns defaults when it does not exist.

func (*ClientConfig) AddNeverSend

func (c *ClientConfig) AddNeverSend(chord string) error

AddNeverSend keeps chord from the host from now on, even while immersive mode takes the system's keys. A bare key, such as F13, is a chord here. It refuses a hotkey's chord, which never reaches the host already.

func (*ClientConfig) ApplyCalibration added in v0.2.0

func (c *ClientConfig) ApplyCalibration(hostKey, route string, r CalibratedRoute) error

ApplyCalibration keeps r for the pinned host hostKey on route, in place of any before it.

func (ClientConfig) Calibration added in v0.2.0

func (c ClientConfig) Calibration(hostKey, route string) (CalibratedRoute, bool)

Calibration is the calibration kept for the pinned host hostKey on route, a discovery.PathKind's String.

func (ClientConfig) CheckPin

func (c ClientConfig) CheckPin(hostID, fingerprint string) (PinnedHost, error)

CheckPin reports whether fingerprint is the one pinned for hostID.

func (ClientConfig) Hotkey

func (c ClientConfig) Hotkey(a HotkeyAction) Chord

Hotkey is a's chord: the user's, or the default. It is zero while a is unbound.

func (ClientConfig) HotkeyChords

func (c ClientConfig) HotkeyChords() map[HotkeyAction]Chord

HotkeyChords are the bound hotkeys' chords.

func (ClientConfig) NeverSendChords

func (c ClientConfig) NeverSendChords() []Chord

NeverSendChords are the chords the client keeps from the host.

func (ClientConfig) OverridesFor

func (c ClientConfig) OverridesFor(hostID string) defaults.UserOverrides

OverridesFor returns the global overrides with hostID's on top.

func (*ClientConfig) Pin

func (c *ClientConfig) Pin(h PinnedHost) error

Pin records a paired host, replacing any earlier pin for the same HostID.

func (*ClientConfig) RemoveNeverSend

func (c *ClientConfig) RemoveNeverSend(chord string) error

RemoveNeverSend sends chord to the host again.

func (*ClientConfig) ResetAllHotkeys

func (c *ClientConfig) ResetAllHotkeys()

ResetAllHotkeys binds every hotkey to its default chord.

func (*ClientConfig) ResetCalibration added in v0.2.0

func (c *ClientConfig) ResetCalibration(hostKey, route string)

ResetCalibration forgets the calibration of hostKey on route, or on every route when route is "", so its streams take the defaults again.

func (*ClientConfig) ResetHotkey

func (c *ClientConfig) ResetHotkey(a HotkeyAction, goos string) error

ResetHotkey binds a to its default chord, unless another hotkey has taken that chord since.

func (*ClientConfig) SetHotkey

func (c *ClientConfig) SetHotkey(a HotkeyAction, chord, goos string) error

SetHotkey binds a to chord, or with "" unbinds it. It refuses a chord without a modifier, one the system keeps on goos, one another hotkey has, and one on the never-send list.

func (ClientConfig) StreamWindows

func (c ClientConfig) StreamWindows() int

StreamWindows is the most stream windows Open every host display opens: MaxStreamWindows as set, in bounds, or the default.

func (ClientConfig) StreamsOpenFullscreen

func (c ClientConfig) StreamsOpenFullscreen() bool

StreamsOpenFullscreen reports whether a stream's window opens in full screen: on unless the user turned it off.

func (ClientConfig) TelemetryOn

func (c ClientConfig) TelemetryOn() bool

TelemetryOn reports whether anonymous usage telemetry may send: on unless the user turned it off.

func (ClientConfig) Validate

func (c ClientConfig) Validate() error

type GamepadConfig

type GamepadConfig struct {
	// The client's processing of its controllers: radial stick deadzones
	// and trigger thresholds in percent, and rumble strength in percent.
	LeftDeadzone     int  `json:"leftDeadzone"`
	RightDeadzone    int  `json:"rightDeadzone"`
	TriggerThreshold int  `json:"triggerThreshold"`
	InvertLeftY      bool `json:"invertLeftY,omitempty"`
	InvertRightY     bool `json:"invertRightY,omitempty"`
	RumbleEnabled    bool `json:"rumbleEnabled"`
	RumbleStrength   int  `json:"rumbleStrength"`
	// Mappings are the SDL gamecontrollerdb lines the user saved, by the
	// controller's SDL GUID; other controllers use their default mapping.
	Mappings map[string]string `json:"mappings,omitempty"`

	// VirtualType is what a host's virtual controllers appear as: one of
	// the VirtualPad constants.
	VirtualType string `json:"virtualType"`
	// AllowGuestGamepads lets clients other than this machine's owner
	// plug in controllers.
	AllowGuestGamepads bool `json:"allowGuestGamepads"`
}

func DefaultGamepadConfig

func DefaultGamepadConfig() GamepadConfig

func LoadGamepadConfig

func LoadGamepadConfig(dir string) (GamepadConfig, error)

LoadGamepadConfig reads <dir>/gamepad.json, or returns defaults when it does not exist.

func (*GamepadConfig) SetMapping

func (c *GamepadConfig) SetMapping(guid, line string)

SetMapping saves an SDL mapping line for its controller's GUID, or removes the saved one when line is empty.

func (GamepadConfig) Validate

func (c GamepadConfig) Validate() error

type HostConfig

type HostConfig struct {
	HostID string `json:"hostID"`
	// Name is what clients see; empty advertises Hostname().
	Name string `json:"name"`
	// ControlPort and MediaPort 0 pick a free port; DiscoveryPort 0 turns
	// LAN discovery off.
	ControlPort   uint16 `json:"controlPort"`
	MediaPort     uint16 `json:"mediaPort"`
	DiscoveryPort uint16 `json:"discoveryPort"`
	Display       string `json:"display,omitempty"`
	// Adapter is the encoding GPU by part of its name; empty lets the host
	// choose.
	Adapter string `json:"adapter,omitempty"`
	// VDDPrimary makes a session's virtual display the primary one.
	VDDPrimary bool `json:"vddPrimary,omitempty"`
	// FixedPIN is a pairing PIN that never changes; empty rotates a random
	// one after each pairing.
	FixedPIN string `json:"fixedPIN,omitempty"`
	// NoInput ignores clients' keyboard, mouse and gamepad.
	NoInput bool `json:"noInput,omitempty"`
	// Clipboard is what the host shares: one of the Clipboard constants,
	// empty is off.
	Clipboard              string `json:"clipboard,omitempty"`
	Codec                  string `json:"codec"`
	Chroma                 string `json:"chroma"`
	FPS                    int    `json:"fps"`
	MaxBitrateKbps         int    `json:"maxBitrateKbps"`
	RequirePINForLAN       bool   `json:"requirePINForLAN"`
	AllowTailscaleSameUser bool   `json:"allowTailscaleSameUser"`
	CertPath               string `json:"certPath"`
	KeyPath                string `json:"keyPath"`
	// Policy becomes HostCapabilities.Forced: it beats the client's overrides.
	Policy defaults.UserOverrides `json:"policy"`

	// AudioDevice is the output device whose sound streams, by
	// audio.Device ID; empty is everything this machine plays.
	AudioDevice string `json:"audioDevice,omitempty"`
	// AudioExcludeApps are apps left out of the streamed sound, by name,
	// such as "Discord"; each session finds their processes.
	AudioExcludeApps AppList `json:"audioExcludeApps,omitempty"`
	// VirtualMic is where a client's microphone plays: empty finds a
	// virtual mic, VirtualMicOff refuses the microphone, and anything else
	// is an output device's ID or part of its name.
	VirtualMic string `json:"virtualMic,omitempty"`

	// StayAwake keeps this machine and its display from sleeping while
	// hosting is on.
	StayAwake bool `json:"stayAwake,omitempty"`
	// LockOnDisconnect locks this machine when a client leaves.
	LockOnDisconnect bool `json:"lockOnDisconnect,omitempty"`
	// MuteSpeakers mutes this machine's speakers while a client streams.
	MuteSpeakers bool `json:"muteSpeakers,omitempty"`
	// PrivacyMode turns this machine's own displays off while a client
	// streams from a virtual display (Windows).
	PrivacyMode bool `json:"privacyMode,omitempty"`
	// IdleTimeoutMinutes disconnects a client that sent no input for that
	// long; 0 is never.
	IdleTimeoutMinutes int `json:"idleTimeoutMinutes,omitempty"`
}

func DefaultHostConfig

func DefaultHostConfig(dir string) HostConfig

DefaultHostConfig returns settings for a new host in dir, with a fresh random HostID and the identity files beside the config.

func LoadHostConfig

func LoadHostConfig(dir string) (HostConfig, error)

LoadHostConfig reads <dir>/host.json. When the file does not exist it returns DefaultHostConfig(dir), which the caller should save so the HostID stays stable.

func (HostConfig) Validate

func (c HostConfig) Validate() error

type HotkeyAction

type HotkeyAction string

HotkeyAction names what a hotkey does.

const (
	HotkeyStreamMenu    HotkeyAction = "streamMenu"
	HotkeyHideButton    HotkeyAction = "hideButton"
	HotkeyMetrics       HotkeyAction = "metrics"
	HotkeyCycleHUD      HotkeyAction = "cycleHUD"
	HotkeyMicrophone    HotkeyAction = "microphone"
	HotkeyFullscreen    HotkeyAction = "fullscreen"
	HotkeyImmersive     HotkeyAction = "immersive"
	HotkeyCursorLock    HotkeyAction = "cursorLock"
	HotkeySwitchDisplay HotkeyAction = "switchDisplay"
	HotkeyCtrlAltDel    HotkeyAction = "ctrlAltDel"
	HotkeyKeyframe      HotkeyAction = "keyframe"
	HotkeyDisconnect    HotkeyAction = "disconnect"
	HotkeyStopHosting   HotkeyAction = "stopHosting"
	HotkeyKickClient    HotkeyAction = "kickClient"
)

The stream's actions, which work in the stream's window, and while immersive mode takes the system's keys, and the host's, which are global: they work while Planck is not in front.

type HotkeyDef

type HotkeyDef struct {
	Action  HotkeyAction
	Default Chord
	// Global is a host action, registered with the desktop so that it
	// fires while Planck is not in front.
	Global bool
}

HotkeyDef is a hotkey's action and its default chord.

type HotkeyError

type HotkeyError struct {
	Chord Chord
	Err   error
	// Owner is the hotkey that has the chord, for ErrChordInUse; empty
	// when the never-send list has it.
	Owner HotkeyAction
	// Reason says what the system does with a reserved chord.
	Reason string
}

HotkeyError is a chord refused for a hotkey or the never-send list.

func (*HotkeyError) Error

func (e *HotkeyError) Error() string

func (*HotkeyError) Unwrap

func (e *HotkeyError) Unwrap() error

type Mods

type Mods uint8

Mods are a chord's modifier keys, without their side.

const (
	ModCtrl Mods = 1 << iota
	ModAlt
	ModShift
	// ModSuper is Cmd on macOS and the Windows key on Windows.
	ModSuper
)

type OverlayLayout

type OverlayLayout struct {
	// Dock is the edge the button is docked to: "left", "right", "top",
	// "bottom", or "" while it floats at Button.
	Dock           string     `json:"dock,omitempty"`
	DockFrac       float64    `json:"dockFrac,omitempty"`
	Button         *Placement `json:"button,omitempty"`
	Metrics        bool       `json:"metrics,omitempty"`
	MetricsPlace   *Placement `json:"metricsPlace,omitempty"`
	MetricsCompact bool       `json:"metricsCompact,omitempty"`
	// ButtonX and ButtonY (the button's centre) and MetricsX and MetricsY
	// (the window's top-left corner) are fractions of the view, from
	// layouts stored before Button and MetricsPlace; the client reads them
	// only when those are missing.
	ButtonX  float64 `json:"buttonX,omitempty"`
	ButtonY  float64 `json:"buttonY,omitempty"`
	MetricsX float64 `json:"metricsX,omitempty"`
	MetricsY float64 `json:"metricsY,omitempty"`
}

OverlayLayout places the stream overlay's button and metrics window, anchored to the stream view's edges or centre so that a new window size keeps them where they were.

type PinnedHost

type PinnedHost struct {
	HostID          string    `json:"hostID"`
	Name            string    `json:"name"`
	CertFingerprint string    `json:"certFingerprint"`
	PairedAt        time.Time `json:"pairedAt"`
	LastAddr        string    `json:"lastAddr,omitempty"`
	// LastLANAddr and LastTailscaleAddr are the host's control addresses
	// on each kind of route it was last reached or found on.
	LastLANAddr       string `json:"lastLANAddr,omitempty"`
	LastTailscaleAddr string `json:"lastTailscaleAddr,omitempty"`
	// Calibrated is what calibration kept for the host, by route: a
	// discovery.PathKind's String.
	Calibrated map[string]CalibratedRoute `json:"calibrated,omitempty"`
}

type Placement

type Placement struct {
	AnchorX string  `json:"anchorX"`
	AnchorY string  `json:"anchorY"`
	OffsetX float64 `json:"offsetX"`
	OffsetY float64 `json:"offsetY"`
}

Placement is where an overlay widget sits on each axis: AnchorX and AnchorY are "start" (left or top), "center" or "end" (right or bottom), and the offsets are DIPs from that edge to the widget's same edge, or, signed, from the view's centre to the widget's.

Jump to

Keyboard shortcuts

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