Documentation
¶
Index ¶
- Constants
- func FleetKey(appDir string) (string, error)
- func MasterKey(appDir string) ([]byte, error)
- func SetFleetKey(appDir, value string) error
- func SetUpstreamEnrolmentKey(appDir, value string) error
- func SetUpstreamWorkerKey(appDir, value string) error
- func UpstreamEnrolmentKey(appDir string) (string, error)
- func UpstreamWorkerKey(appDir string) (string, error)
- type AppConfig
- type Manager
Constants ¶
const DefaultUpstreamIntervalMinutes = 1
DefaultUpstreamIntervalMinutes matches what a CashPilot worker sends, so a paired Desktop does not look stale next to the Docker workers on the same fleet page — the server marks a worker unreachable on heartbeat age.
Variables ¶
This section is empty.
Functions ¶
func FleetKey ¶ added in v0.10.0
FleetKey returns the stored fleet bearer token, mirroring MasterKey's keychain-preferred / file-fallback storage. It tries the OS keychain first, then a 0600 <appDir>/.fleet_api_key file (migrating that file's value into the keychain when found). An empty string with a nil error means "not stored yet" so the caller can generate a fresh token or migrate a legacy config.json value and persist it via SetFleetKey.
func SetFleetKey ¶ added in v0.10.0
SetFleetKey persists the fleet bearer token keychain-first, falling back to a 0600 <appDir>/.fleet_api_key file when the keychain is unavailable (headless Linux / CI), exactly like MasterKey's storage tail.
func SetUpstreamEnrolmentKey ¶ added in v0.12.0
SetUpstreamEnrolmentKey persists the shared enrolment token.
func SetUpstreamWorkerKey ¶ added in v0.12.0
SetUpstreamWorkerKey persists the per-worker key issued by the server.
func UpstreamEnrolmentKey ¶ added in v0.12.0
UpstreamEnrolmentKey returns the shared CashPilot token used to enrol this machine, or "" when not stored. Same keychain-first, 0600-file-fallback storage as FleetKey.
func UpstreamWorkerKey ¶ added in v0.12.0
UpstreamWorkerKey returns the per-worker key the server issued to this machine, or "" before enrolment completes.
Types ¶
type AppConfig ¶
type AppConfig struct {
FirstRunComplete bool `json:"firstRunComplete"`
DisplayCurrency string `json:"displayCurrency"`
RuntimeProvider string `json:"runtimeProvider"`
AutoUpdate bool `json:"autoUpdate"`
HostnamePrefix string `json:"hostnamePrefix"`
CollectIntervalMinutes int `json:"collectIntervalMinutes"`
RetentionDays int `json:"retentionDays"`
Timezone string `json:"timezone"`
// FleetAPIKey is the legacy plaintext location for the fleet bearer token. It is
// no longer persisted here — the token lives in the OS keychain with a 0600 file
// fallback via FleetKey/SetFleetKey. The field is retained with omitempty only so
// an older config.json still unmarshals and ensureFleetAPIKey can migrate its
// value into the keychain and then blank it from disk.
FleetAPIKey string `json:"fleetApiKey,omitempty"`
FleetBindAddress string `json:"fleetBindAddress"`
FleetPort int `json:"fleetPort"`
// MetricsEnabled turns on the opt-in Prometheus /metrics endpoint on the fleet
// server. It defaults to false (disabled) — the bool zero value, so applyDefaults
// needs no change. Enabling it exposes earnings, health and fleet stats on the
// fleet bind address (loopback by default) with no authentication, matching the
// Prometheus scraping convention.
MetricsEnabled bool `json:"metricsEnabled"`
// WorkerURLPolicy selects how the SSRF worker-URL validator (internal/fleetnet)
// classifies a remote worker endpoint before the desktop makes an authenticated
// request to it. One of "strict" (only WorkerAllowedHosts), "private" (RFC1918 +
// Tailscale CGNAT 100.64.0.0/10 + IPv6 ULA fc00::/7 + the allowlist — the sensible
// homelab default), or "public" (any non-loopback/link-local/metadata/unspecified
// address). Defaults to "private" via applyDefaults.
WorkerURLPolicy string `json:"workerUrlPolicy"`
// WorkerAllowedHosts is an explicit allowlist of worker hosts/IPs. It is the sole
// allow-source in "strict" mode and is always honored in the other modes. Entries
// may be an exact hostname, a "*.suffix" DNS suffix (e.g. Tailscale MagicDNS
// "*.mango-alpha.ts.net"), a CIDR, or a literal IP. Defaults to empty (nil).
WorkerAllowedHosts []string `json:"workerAllowedHosts"`
// WorkerAllowMetadata, when false (the default, the bool zero value), makes the
// cloud instance-metadata endpoints (169.254.169.254, fd00:ec2::254,
// metadata.google.internal) ALWAYS blocked regardless of policy or allowlist.
// Setting it true is the only way to reach a metadata address and should be rare.
WorkerAllowMetadata bool `json:"workerAllowMetadata"`
// UpstreamURL optionally pairs this Desktop with a CashPilot server, which it
// then reports to as a worker. EMPTY IS THE DEFAULT AND MEANS STANDALONE:
// Desktop keeps working exactly as before and nothing is sent anywhere.
//
// The credentials are deliberately NOT here — they live in the OS keychain
// (0600 file fallback) via UpstreamEnrolmentKey/UpstreamWorkerKey, the same
// way the fleet token does, so config.json never carries a bearer token.
UpstreamURL string `json:"upstreamUrl,omitempty"`
// UpstreamIntervalMinutes is how often to heartbeat when paired. Zero means
// use the default; see DefaultUpstreamIntervalMinutes.
UpstreamIntervalMinutes int `json:"upstreamIntervalMinutes,omitempty"`
}