Documentation
¶
Index ¶
- Constants
- Variables
- func ClearAuthCfgForTesting()
- func GetAuthCfg() map[string]CredentialEntry
- func LoadAuthFromData(data []byte) map[string]CredentialEntry
- func SetAuthCfgForTesting(creds map[string]CredentialEntry)
- type Audio
- type CredentialEntry
- type Discovery
- type DriverConfig
- type DriverInfo
- type Groovy
- type Input
- type Instance
- func (c *Instance) APIListen() string
- func (c *Instance) APIPort() int
- func (c *Instance) AllowedIPs() []string
- func (c *Instance) AllowedOrigins() []string
- func (c *Instance) AudioFeedback() bool
- func (c *Instance) AutoDetect() bool
- func (c *Instance) CustomLaunchers() []LaunchersCustom
- func (c *Instance) DailyLimit() time.Duration
- func (c *Instance) DebugLogging() bool
- func (c *Instance) DefaultLangs() []string
- func (c *Instance) DefaultMediaDir() string
- func (c *Instance) DefaultRegions() []string
- func (c *Instance) DeviceID() string
- func (c *Instance) DiscoveryEnabled() bool
- func (c *Instance) DiscoveryInstanceName() string
- func (c *Instance) ErrorReporting() bool
- func (c *Instance) FailSoundPath(dataDir string) (string, bool)
- func (c *Instance) FilenameTags() bool
- func (c *Instance) GetMQTTPublishers() []MQTTPublisher
- func (c *Instance) GmcProxyBeaconInterval() string
- func (c *Instance) GmcProxyEnabled() bool
- func (c *Instance) GmcProxyPort() int
- func (c *Instance) HoldModeEnabled() bool
- func (c *Instance) IndexRoots() []string
- func (c *Instance) IsDriverAutoDetectEnabled(driverID string, defaultAutoDetect bool) bool
- func (c *Instance) IsDriverEnabled(driverID string, defaultEnabled bool) bool
- func (c *Instance) IsDriverEnabledForAutoDetect(driver DriverInfo) bool
- func (c *Instance) IsDriverEnabledForConnect(driver DriverInfo) bool
- func (c *Instance) IsExecuteAllowed(s string) bool
- func (c *Instance) IsHoldModeIgnoredSystem(systemID string) bool
- func (c *Instance) IsLauncherFileAllowed(s string) bool
- func (c *Instance) IsRunAllowed(s string) bool
- func (c *Instance) LaunchersBeforeMediaStart() string
- func (c *Instance) LaunchersOnMediaStart() string
- func (c *Instance) LimitSoundPath(dataDir string) (string, bool)
- func (c *Instance) Load() error
- func (c *Instance) LoadCustomLaunchers(launchersDir string) error
- func (c *Instance) LoadMappings(mappingsDir string) error
- func (c *Instance) LookupLauncherDefaults(launcherID string) (LaunchersDefault, bool)
- func (c *Instance) LookupSystemDefaults(systemID string) (SystemsDefault, bool)
- func (c *Instance) Mappings() []MappingsEntry
- func (c *Instance) PlaytimeLimitsEnabled() bool
- func (c *Instance) PlaytimeRetention() int
- func (c *Instance) Readers() Readers
- func (c *Instance) ReadersScan() ReadersScan
- func (c *Instance) Save() error
- func (c *Instance) ScanHistory() int
- func (c *Instance) SessionLimit() time.Duration
- func (c *Instance) SessionResetTimeout() time.Duration
- func (c *Instance) SetAPIPort(port int) error
- func (c *Instance) SetAudioFeedback(enabled bool)
- func (c *Instance) SetAutoDetect(enabled bool)
- func (c *Instance) SetDailyLimit(duration string) error
- func (c *Instance) SetDebugLogging(enabled bool)
- func (c *Instance) SetDiscoveryEnabled(enabled bool)
- func (c *Instance) SetDiscoveryInstanceName(name string)
- func (c *Instance) SetErrorReporting(enabled bool)
- func (c *Instance) SetExecuteAllowListForTesting(allowList []string)
- func (c *Instance) SetFilenameTags(enabled bool)
- func (c *Instance) SetLauncherDefaultsForTesting(defaults []LaunchersDefault)
- func (c *Instance) SetPlaytimeLimitsEnabled(enabled bool)
- func (c *Instance) SetPlaytimeRetention(days int)
- func (c *Instance) SetReaderConnections(rcs []ReadersConnect)
- func (c *Instance) SetScanExitDelay(exitDelay float32)
- func (c *Instance) SetScanIgnoreSystem(ignoreSystem []string)
- func (c *Instance) SetScanMode(mode string)
- func (c *Instance) SetSessionLimit(duration string) error
- func (c *Instance) SetSessionResetTimeout(duration *string) error
- func (c *Instance) SetSystemDefaultsForTesting(defaults []SystemsDefault)
- func (c *Instance) SetVirtualGamepadEnabled(enabled bool)
- func (c *Instance) SetWarningIntervals(intervals []string) error
- func (c *Instance) SuccessSoundPath(dataDir string) (string, bool)
- func (c *Instance) SystemDefaults() []SystemsDefault
- func (c *Instance) TapModeEnabled() bool
- func (c *Instance) VirtualGamepadEnabled(defaultEnabled bool) bool
- func (c *Instance) WarningIntervals() []time.Duration
- type Launchers
- type LaunchersCustom
- type LaunchersDefault
- type MQTTPublisher
- type Mappings
- type MappingsEntry
- type Media
- type Playtime
- type PlaytimeLimits
- type Publishers
- type Readers
- type ReadersConnect
- type ReadersScan
- type Service
- type Systems
- type SystemsDefault
- type Values
- type ZapScript
Constants ¶
const ( AppName = "zaparoo" MediaDbFile = "media.db" UserDbFile = "user.db" LogFile = "core.log" PidFile = "core.pid" CfgFile = "config.toml" AuthFile = "auth.toml" UserDir = "user" LogsDir = "logs" APIRequestTimeout = 30 * time.Second SuccessSoundFilename = "success.wav" FailSoundFilename = "fail.wav" LimitSoundFilename = "limit.wav" AssetsDir = "assets" MappingsDir = "mappings" LaunchersDir = "launchers" MediaDir = "media" )
const ( SchemaVersion = 1 CfgEnv = "ZAPAROO_CFG" AppEnv = "ZAPAROO_APP" ScanModeTap = "tap" ScanModeHold = "hold" )
const ( DefaultGmcProxyPort = 32106 DefaultGmcProxyBeaconInterval = "2s" )
const ( DefaultAPIPort = 7497 MinAPIPort = 1024 MaxAPIPort = 65535 )
Variables ¶
var AppVersion = "DEVELOPMENT"
var BaseDefaults = Values{ ConfigSchema: SchemaVersion, Audio: Audio{ ScanFeedback: true, }, Readers: Readers{ AutoDetect: true, Scan: ReadersScan{ Mode: ScanModeTap, }, }, }
Functions ¶
func ClearAuthCfgForTesting ¶
func ClearAuthCfgForTesting()
ClearAuthCfgForTesting clears the global auth config for testing purposes
func GetAuthCfg ¶
func GetAuthCfg() map[string]CredentialEntry
func LoadAuthFromData ¶ added in v2.8.0
func LoadAuthFromData(data []byte) map[string]CredentialEntry
LoadAuthFromData parses auth.toml data supporting all three formats. Formats are merged, allowing users to mix formats in the same file.
Supported formats:
- Root level: ["https://example.com"]
- Creds wrapper: [creds."https://example.com"]
- Auth.creds wrapper: [auth.creds."https://example.com"]
func SetAuthCfgForTesting ¶
func SetAuthCfgForTesting(creds map[string]CredentialEntry)
SetAuthCfgForTesting sets the global auth config for testing purposes
Types ¶
type CredentialEntry ¶
type CredentialEntry struct {
Username string `toml:"username"`
Password string `toml:"password"`
Bearer string `toml:"bearer"`
}
CredentialEntry holds authentication credentials for a URL.
func LookupAuth ¶
func LookupAuth(creds map[string]CredentialEntry, reqURL string) *CredentialEntry
LookupAuth finds credentials for a URL using fallback matching.
The lookup tries 3 match types in order of decreasing specificity:
- Exact scheme match - scheme, host, and path prefix must match exactly
- Canonical scheme match - normalized schemes match (e.g., tcp://x matches mqtt://x config)
- Schemeless host:port match - for entries like "broker:1883" that match any scheme
This design allows:
- Strict scheme matching for security-sensitive protocols (http vs https)
- Flexible matching for protocols with multiple equivalent schemes (mqtt/tcp/ssl)
- Simple host:port entries for services where scheme doesn't matter
type DriverConfig ¶
type DriverInfo ¶ added in v2.8.0
DriverInfo contains driver metadata needed for enabled/auto-detect checks. This is a subset of reader metadata to avoid circular imports.
type Input ¶ added in v2.7.1
type Input struct {
GamepadEnabled *bool `toml:"gamepad_enabled,omitempty"`
}
type Instance ¶
type Instance struct {
// contains filtered or unexported fields
}
func (*Instance) AllowedIPs ¶ added in v2.7.0
func (*Instance) AllowedOrigins ¶
func (*Instance) AudioFeedback ¶
func (*Instance) AutoDetect ¶
func (*Instance) CustomLaunchers ¶
func (c *Instance) CustomLaunchers() []LaunchersCustom
func (*Instance) DailyLimit ¶ added in v2.7.0
DailyLimit returns the daily time limit as a duration. Returns 0 if not configured or if the duration cannot be parsed.
func (*Instance) DebugLogging ¶
func (*Instance) DefaultLangs ¶ added in v2.7.0
DefaultLangs returns the list of default languages for media matching.
func (*Instance) DefaultMediaDir ¶
func (*Instance) DefaultRegions ¶ added in v2.7.0
DefaultRegions returns the list of default regions for media matching.
func (*Instance) DiscoveryEnabled ¶ added in v2.8.0
func (*Instance) DiscoveryInstanceName ¶ added in v2.8.0
func (*Instance) ErrorReporting ¶ added in v2.8.0
ErrorReporting returns whether error reporting is enabled. Defaults to false (opt-in).
func (*Instance) FailSoundPath ¶ added in v2.7.0
FailSoundPath returns the resolved path to the fail sound file and whether it's enabled. Returns ("", true) if nil (use embedded default), ("", false) if disabled (empty string), or (resolved_path, true) if a custom path is configured. For relative paths, dataDir is used as the base (typically helpers.DataDir(pl)).
func (*Instance) FilenameTags ¶ added in v2.7.0
FilenameTags returns whether filename tag parsing is enabled.
func (*Instance) GetMQTTPublishers ¶ added in v2.7.0
func (c *Instance) GetMQTTPublishers() []MQTTPublisher
func (*Instance) GmcProxyBeaconInterval ¶
func (*Instance) GmcProxyEnabled ¶
func (*Instance) GmcProxyPort ¶
func (*Instance) HoldModeEnabled ¶
func (*Instance) IndexRoots ¶
func (*Instance) IsDriverAutoDetectEnabled ¶
func (*Instance) IsDriverEnabled ¶
func (*Instance) IsDriverEnabledForAutoDetect ¶ added in v2.8.0
func (c *Instance) IsDriverEnabledForAutoDetect(driver DriverInfo) bool
IsDriverEnabledForAutoDetect checks if a driver should be enabled for auto-detection. Uses the driver's DefaultEnabled if not explicitly configured.
func (*Instance) IsDriverEnabledForConnect ¶ added in v2.8.0
func (c *Instance) IsDriverEnabledForConnect(driver DriverInfo) bool
IsDriverEnabledForConnect checks if a driver should be enabled for a user-defined [[readers.connect]] entry. Returns true unless explicitly disabled. Having a connect entry implicitly enables the driver.
func (*Instance) IsExecuteAllowed ¶
func (*Instance) IsHoldModeIgnoredSystem ¶
func (*Instance) IsLauncherFileAllowed ¶
func (*Instance) IsRunAllowed ¶
func (*Instance) LaunchersBeforeMediaStart ¶ added in v2.8.0
func (*Instance) LaunchersOnMediaStart ¶
func (*Instance) LimitSoundPath ¶ added in v2.7.0
LimitSoundPath returns the resolved path to the limit sound file and whether it's enabled. Returns ("", true) if nil (use embedded default), ("", false) if disabled (empty string), or (resolved_path, true) if a custom path is configured. For relative paths, dataDir is used as the base (typically helpers.DataDir(pl)).
func (*Instance) LoadCustomLaunchers ¶
func (*Instance) LoadMappings ¶
func (*Instance) LookupLauncherDefaults ¶
func (c *Instance) LookupLauncherDefaults(launcherID string) (LaunchersDefault, bool)
func (*Instance) LookupSystemDefaults ¶
func (c *Instance) LookupSystemDefaults(systemID string) (SystemsDefault, bool)
func (*Instance) Mappings ¶
func (c *Instance) Mappings() []MappingsEntry
func (*Instance) PlaytimeLimitsEnabled ¶ added in v2.7.0
PlaytimeLimitsEnabled returns true if play time limits are enabled.
func (*Instance) PlaytimeRetention ¶ added in v2.7.0
PlaytimeRetention returns the number of days to retain play time history. Returns 0 if cleanup is disabled, or 365 (1 year) by default.
func (*Instance) ReadersScan ¶
func (c *Instance) ReadersScan() ReadersScan
func (*Instance) ScanHistory ¶ added in v2.7.0
func (*Instance) SessionLimit ¶ added in v2.7.0
SessionLimit returns the per-session time limit as a duration. Returns 0 if not configured or if the duration cannot be parsed.
func (*Instance) SessionResetTimeout ¶ added in v2.7.0
SessionResetTimeout returns the idle timeout before a session resets. Returns 20 minutes by default if not configured (nil). Returns 0 if explicitly set to "0" (no timeout, session never resets).
func (*Instance) SetAPIPort ¶ added in v2.7.1
func (*Instance) SetAudioFeedback ¶
func (*Instance) SetAutoDetect ¶
func (*Instance) SetDailyLimit ¶ added in v2.7.0
SetDailyLimit sets the daily time limit from a duration string (e.g., "2h30m"). Returns an error if the duration string is invalid. Pass empty string to disable daily limit.
func (*Instance) SetDebugLogging ¶
func (*Instance) SetDiscoveryEnabled ¶ added in v2.8.0
func (*Instance) SetDiscoveryInstanceName ¶ added in v2.8.0
func (*Instance) SetErrorReporting ¶ added in v2.8.0
SetErrorReporting sets whether error reporting is enabled.
func (*Instance) SetExecuteAllowListForTesting ¶ added in v2.8.0
SetExecuteAllowListForTesting configures the execute allow list for tests.
func (*Instance) SetFilenameTags ¶ added in v2.7.0
SetFilenameTags sets whether filename tag parsing is enabled.
func (*Instance) SetLauncherDefaultsForTesting ¶ added in v2.8.0
func (c *Instance) SetLauncherDefaultsForTesting(defaults []LaunchersDefault)
SetLauncherDefaultsForTesting sets launcher defaults for testing purposes.
func (*Instance) SetPlaytimeLimitsEnabled ¶ added in v2.7.0
SetPlaytimeLimitsEnabled enables or disables playtime limits.
func (*Instance) SetPlaytimeRetention ¶ added in v2.7.0
SetPlaytimeRetention sets the number of days to retain play time history. Pass 0 to disable cleanup.
func (*Instance) SetReaderConnections ¶
func (c *Instance) SetReaderConnections(rcs []ReadersConnect)
func (*Instance) SetScanExitDelay ¶
func (*Instance) SetScanIgnoreSystem ¶
func (*Instance) SetScanMode ¶
func (*Instance) SetSessionLimit ¶ added in v2.7.0
SetSessionLimit sets the session time limit from a duration string (e.g., "45m"). Returns an error if the duration string is invalid. Pass empty string to disable session limit.
func (*Instance) SetSessionResetTimeout ¶ added in v2.7.0
SetSessionResetTimeout sets the idle timeout before a session resets (e.g., "20m", "1h", "0"). Returns an error if the duration string is invalid. Pass nil to use default (20 minutes). Pass "0" to disable session reset timeout.
func (*Instance) SetSystemDefaultsForTesting ¶ added in v2.7.0
func (c *Instance) SetSystemDefaultsForTesting(defaults []SystemsDefault)
SetSystemDefaultsForTesting sets system defaults for testing purposes
func (*Instance) SetVirtualGamepadEnabled ¶ added in v2.7.1
SetVirtualGamepadEnabled sets whether virtual gamepad emulation is enabled.
func (*Instance) SetWarningIntervals ¶ added in v2.7.0
SetWarningIntervals sets the warning intervals from duration strings (e.g., ["10m", "5m", "2m"]). Returns an error if any duration string is invalid. Pass empty slice to use defaults [5m, 2m, 1m].
func (*Instance) SuccessSoundPath ¶ added in v2.7.0
SuccessSoundPath returns the resolved path to the success sound file and whether it's enabled. Returns ("", true) if nil (use embedded default), ("", false) if disabled (empty string), or (resolved_path, true) if a custom path is configured. For relative paths, dataDir is used as the base (typically helpers.DataDir(pl)).
func (*Instance) SystemDefaults ¶
func (c *Instance) SystemDefaults() []SystemsDefault
func (*Instance) TapModeEnabled ¶
func (*Instance) VirtualGamepadEnabled ¶ added in v2.7.1
VirtualGamepadEnabled returns whether virtual gamepad emulation is enabled. The defaultEnabled parameter allows platforms to specify their own default.
func (*Instance) WarningIntervals ¶ added in v2.7.0
WarningIntervals returns the warning intervals as durations. Returns default intervals [5m, 2m, 1m] if not configured. Skips any intervals that cannot be parsed.
type Launchers ¶
type Launchers struct {
IndexRoot []string `toml:"index_root,omitempty,multiline"`
AllowFile []string `toml:"allow_file,omitempty,multiline"`
MediaDir string `toml:"media_dir,omitempty"`
BeforeMediaStart string `toml:"before_media_start,omitempty"`
OnMediaStart string `toml:"on_media_start,omitempty"`
Default []LaunchersDefault `toml:"default,omitempty"`
Custom []LaunchersCustom `toml:"custom,omitempty"`
// contains filtered or unexported fields
}
type LaunchersCustom ¶
type LaunchersDefault ¶
type LaunchersDefault struct {
Launcher string `toml:"launcher"`
InstallDir string `toml:"install_dir,omitempty"`
ServerURL string `toml:"server_url,omitempty"`
// Action specifies the default launch action. Common values:
// - "" or "run": Default behavior (launch/play the media)
// - "details": Show media details/info page instead of launching
Action string `toml:"action,omitempty"`
}
type MQTTPublisher ¶ added in v2.7.0
type Mappings ¶
type Mappings struct {
Entry []MappingsEntry `toml:"entry,omitempty"`
}
type MappingsEntry ¶
type Playtime ¶ added in v2.7.0
type Playtime struct {
Retention *int `toml:"retention,omitempty"`
Limits PlaytimeLimits `toml:"limits,omitempty"`
}
Playtime configures play time tracking and limits.
type PlaytimeLimits ¶ added in v2.7.0
type PlaytimeLimits struct {
Enabled *bool `toml:"enabled,omitempty"`
Daily string `toml:"daily,omitempty"`
Session string `toml:"session,omitempty"`
SessionReset *string `toml:"session_reset,omitempty"`
Warnings []string `toml:"warnings,omitempty,multiline"`
}
PlaytimeLimits configures time limits and warnings for gameplay sessions.
type Publishers ¶ added in v2.7.0
type Publishers struct {
MQTT []MQTTPublisher `toml:"mqtt,omitempty"`
}
type Readers ¶
type Readers struct {
Drivers map[string]DriverConfig `toml:"drivers,omitempty"`
ScanHistory *int `toml:"scan_history,omitempty"`
Connect []ReadersConnect `toml:"connect,omitempty"`
Scan ReadersScan `toml:"scan,omitempty"`
AutoDetect bool `toml:"auto_detect"`
}
type ReadersConnect ¶
type ReadersConnect struct {
Driver string `toml:"driver"`
Path string `toml:"path,omitempty"`
IDSource string `toml:"id_source,omitempty"`
}
func (ReadersConnect) ConnectionString ¶
func (r ReadersConnect) ConnectionString() string
type ReadersScan ¶
type Service ¶
type Service struct {
APIPort *int `toml:"api_port,omitempty"`
Discovery Discovery `toml:"discovery,omitempty"`
DeviceID string `toml:"device_id"`
APIListen string `toml:"api_listen,omitempty"`
AllowRun []string `toml:"allow_run,omitempty,multiline"`
AllowedOrigins []string `toml:"allowed_origins,omitempty"`
AllowedIPs []string `toml:"allowed_ips,omitempty"`
Publishers Publishers `toml:"publishers,omitempty"`
// contains filtered or unexported fields
}
type Systems ¶
type Systems struct {
Default []SystemsDefault `toml:"default,omitempty"`
}
type SystemsDefault ¶
type Values ¶
type Values struct {
Audio Audio `toml:"audio"`
Input Input `toml:"input,omitempty"`
Launchers Launchers `toml:"launchers,omitempty"`
Media Media `toml:"media,omitempty"`
Playtime Playtime `toml:"playtime,omitempty"`
ZapScript ZapScript `toml:"zapscript,omitempty"`
Systems Systems `toml:"systems,omitempty"`
Mappings Mappings `toml:"mappings,omitempty"`
Service Service `toml:"service,omitempty"`
Groovy Groovy `toml:"groovy,omitempty"`
Readers Readers `toml:"readers,omitempty"`
ConfigSchema int `toml:"config_schema"`
DebugLogging bool `toml:"debug_logging"`
ErrorReporting bool `toml:"error_reporting"`
}