config

package
v2.6.0 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2025 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AppName              = "zaparoo"
	MediaDbFile          = "media.db"
	UserDbFile           = "user.db"
	LogFile              = "core.log"
	PidFile              = "core.pid"
	CfgFile              = "config.toml"
	AuthFile             = "auth.toml"
	UserDir              = "user"
	APIRequestTimeout    = 30 * time.Second
	SuccessSoundFilename = "success.wav"
	FailSoundFilename    = "fail.wav"
	AssetsDir            = "assets"
	MappingsDir          = "mappings"
	LaunchersDir         = "launchers"
	MediaDir             = "media"
)
View Source
const (
	SchemaVersion = 1
	CfgEnv        = "ZAPAROO_CFG"
	AppEnv        = "ZAPAROO_APP"
	ScanModeTap   = "tap"
	ScanModeHold  = "hold"
)

Variables

View Source
var AppVersion = "DEVELOPMENT"
View Source
var BaseDefaults = Values{
	ConfigSchema: SchemaVersion,
	Audio: Audio{
		ScanFeedback: true,
	},
	Readers: Readers{
		AutoDetect: true,
		Scan: ReadersScan{
			Mode: ScanModeTap,
		},
	},
	Service: Service{
		APIPort: 7497,
	},
	Groovy: Groovy{
		GmcProxyEnabled:        false,
		GmcProxyPort:           32106,
		GmcProxyBeaconInterval: "2s",
	},
}

Functions

func ClearAuthCfgForTesting

func ClearAuthCfgForTesting()

ClearAuthCfgForTesting clears the global auth config for testing purposes

func SetAuthCfgForTesting

func SetAuthCfgForTesting(auth Auth)

SetAuthCfgForTesting sets the global auth config for testing purposes

Types

type Audio

type Audio struct {
	ScanFeedback bool `toml:"scan_feedback,omitempty"`
}

type Auth

type Auth struct {
	Creds map[string]CredentialEntry `toml:"creds,omitempty"`
}

func GetAuthCfg

func GetAuthCfg() Auth

type CredentialEntry

type CredentialEntry struct {
	Username string `toml:"username"`
	Password string `toml:"password"`
	Bearer   string `toml:"bearer"`
}

func LookupAuth

func LookupAuth(authCfg Auth, reqURL string) *CredentialEntry

type DriverConfig

type DriverConfig struct {
	Enabled    *bool `toml:"enabled,omitempty"`
	AutoDetect *bool `toml:"auto_detect,omitempty"`
}

type Groovy

type Groovy struct {
	GmcProxyBeaconInterval string `toml:"gmc_proxy_beacon_interval"`
	GmcProxyPort           int    `toml:"gmc_proxy_port"`
	GmcProxyEnabled        bool   `toml:"gmc_proxy_enabled"`
}

type Instance

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

func NewConfig

func NewConfig(configDir string, defaults Values) (*Instance, error)

func (*Instance) APIPort

func (c *Instance) APIPort() int

func (*Instance) AllowedOrigins

func (c *Instance) AllowedOrigins() []string

func (*Instance) AudioFeedback

func (c *Instance) AudioFeedback() bool

func (*Instance) AutoDetect

func (c *Instance) AutoDetect() bool

func (*Instance) CustomLaunchers

func (c *Instance) CustomLaunchers() []LaunchersCustom

func (*Instance) DebugLogging

func (c *Instance) DebugLogging() bool

func (*Instance) DefaultMediaDir

func (c *Instance) DefaultMediaDir() string

func (*Instance) GmcProxyBeaconInterval

func (c *Instance) GmcProxyBeaconInterval() string

func (*Instance) GmcProxyEnabled

func (c *Instance) GmcProxyEnabled() bool

func (*Instance) GmcProxyPort

func (c *Instance) GmcProxyPort() int

func (*Instance) HoldModeEnabled

func (c *Instance) HoldModeEnabled() bool

func (*Instance) IndexRoots

func (c *Instance) IndexRoots() []string

func (*Instance) IsDriverAutoDetectEnabled

func (c *Instance) IsDriverAutoDetectEnabled(driverID string, defaultAutoDetect bool) bool

func (*Instance) IsDriverEnabled

func (c *Instance) IsDriverEnabled(driverID string, defaultEnabled bool) bool

func (*Instance) IsExecuteAllowed

func (c *Instance) IsExecuteAllowed(s string) bool

func (*Instance) IsHoldModeIgnoredSystem

func (c *Instance) IsHoldModeIgnoredSystem(systemID string) bool

func (*Instance) IsLauncherFileAllowed

func (c *Instance) IsLauncherFileAllowed(s string) bool

func (*Instance) IsRunAllowed

func (c *Instance) IsRunAllowed(s string) bool

func (*Instance) LaunchersOnMediaStart

func (c *Instance) LaunchersOnMediaStart() string

func (*Instance) Load

func (c *Instance) Load() error

func (*Instance) LoadCustomLaunchers

func (c *Instance) LoadCustomLaunchers(launchersDir string) error

func (*Instance) LoadMappings

func (c *Instance) LoadMappings(mappingsDir string) error

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) Readers

func (c *Instance) Readers() Readers

func (*Instance) ReadersScan

func (c *Instance) ReadersScan() ReadersScan

func (*Instance) Save

func (c *Instance) Save() error

func (*Instance) SetAudioFeedback

func (c *Instance) SetAudioFeedback(enabled bool)

func (*Instance) SetAutoDetect

func (c *Instance) SetAutoDetect(enabled bool)

func (*Instance) SetDebugLogging

func (c *Instance) SetDebugLogging(enabled bool)

func (*Instance) SetReaderConnections

func (c *Instance) SetReaderConnections(rcs []ReadersConnect)

func (*Instance) SetScanExitDelay

func (c *Instance) SetScanExitDelay(exitDelay float32)

func (*Instance) SetScanIgnoreSystem

func (c *Instance) SetScanIgnoreSystem(ignoreSystem []string)

func (*Instance) SetScanMode

func (c *Instance) SetScanMode(mode string)

func (*Instance) SystemDefaults

func (c *Instance) SystemDefaults() []SystemsDefault

func (*Instance) TapModeEnabled

func (c *Instance) TapModeEnabled() bool

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"`
	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 LaunchersCustom struct {
	ID        string   `toml:"id"`
	System    string   `toml:"system"`
	Execute   string   `toml:"execute"`
	MediaDirs []string `toml:"media_dirs"`
	FileExts  []string `toml:"file_exts"`
}

type LaunchersDefault

type LaunchersDefault struct {
	Launcher   string `toml:"launcher"`
	InstallDir string `toml:"install_dir,omitempty"`
	ServerURL  string `toml:"server_url,omitempty"`
}

type Mappings

type Mappings struct {
	Entry []MappingsEntry `toml:"entry,omitempty"`
}

type MappingsEntry

type MappingsEntry struct {
	TokenKey     string `toml:"token_key,omitempty"`
	MatchPattern string `toml:"match_pattern"`
	ZapScript    string `toml:"zapscript"`
}

type Readers

type Readers struct {
	Drivers    map[string]DriverConfig `toml:"drivers,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 ReadersScan struct {
	Mode         string   `toml:"mode"`
	OnScan       string   `toml:"on_scan,omitempty"`
	OnRemove     string   `toml:"on_remove,omitempty"`
	IgnoreSystem []string `toml:"ignore_system,omitempty"`
	ExitDelay    float32  `toml:"exit_delay,omitempty"`
}

type Service

type Service struct {
	DeviceID string   `toml:"device_id"`
	AllowRun []string `toml:"allow_run,omitempty,multiline"`

	AllowedOrigins []string `toml:"allowed_origins,omitempty"`
	APIPort        int      `toml:"api_port"`
	// contains filtered or unexported fields
}

type Systems

type Systems struct {
	Default []SystemsDefault `toml:"default,omitempty"`
}

type SystemsDefault

type SystemsDefault struct {
	System     string `toml:"system"`
	Launcher   string `toml:"launcher,omitempty"`
	BeforeExit string `toml:"before_exit,omitempty"`
}

type Values

type Values struct {
	Launchers    Launchers `toml:"launchers,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"`
	Audio        Audio     `toml:"audio,omitempty"`
	DebugLogging bool      `toml:"debug_logging"`
}

type ZapScript

type ZapScript struct {
	AllowExecute []string `toml:"allow_execute,omitempty,multiline"`
	// contains filtered or unexported fields
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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