Documentation
¶
Index ¶
- Constants
- func ConfigDir() string
- func ExpandTildePath(path string) (string, error)
- func LogDir() string
- func RegisterService(cfg ServiceConfig) error
- func StartService() error
- func StopService() error
- func UnregisterService() error
- func ValidateTemplateParam(template, param string) error
- type APIConfig
- type AppBinaryFinder
- type AppConfig
- type BinaryFinder
- type ConfigStore
- type Connector
- type FilterConfig
- type LocalStore
- type NetworkConfig
- type NotificationPrefs
- type OSManager
- type OutputConfig
- type ServiceConfig
- type ServiceManager
- type ServiceStatus
- type SetupPlan
- type SetupRunner
- type TrayConfig
Constants ¶
const ( // NotifyPrefBlocksMinted is the preference key for block minting alerts. NotifyPrefBlocksMinted = "Blocks minted" // NotifyPrefIncomingTx is the preference key for incoming transaction alerts. NotifyPrefIncomingTx = "Incoming transactions" // NotifyPrefOutgoingTx is the preference key for outgoing transaction alerts. NotifyPrefOutgoingTx = "Outgoing transactions" // NotifyPrefTokenTransfers is the preference key for token transfer alerts. NotifyPrefTokenTransfers = "Token transfers" // NotifyPrefGovProposals is the preference key for new governance proposals. NotifyPrefGovProposals = "New governance proposals" // NotifyPrefVotesCast is the preference key for votes cast alerts. NotifyPrefVotesCast = "Votes cast" // NotifyPrefRegChanges is the preference key for registration change alerts. NotifyPrefRegChanges = "Registration changes" // NotifyPrefPoolParams is the preference key for pool parameter change alerts. NotifyPrefPoolParams = "Pool parameter changes" // NotifyPrefConnectionIssues is the preference key for connection status // alerts. NotifyPrefConnectionIssues = "Connection issues" )
Variables ¶
This section is empty.
Functions ¶
func ConfigDir ¶
func ConfigDir() string
ConfigDir returns the platform-specific directory for storing configuration files. It can be overridden by the ADDER_TRAY_CONFIG_DIR environment variable.
func ExpandTildePath ¶
ExpandTildePath expands the '~' prefix in a file path to the user's home directory. Returns the original path if no expansion is needed.
func LogDir ¶
func LogDir() string
LogDir returns the platform-specific directory for storing log files. It can be overridden by the ADDER_TRAY_LOG_DIR environment variable.
func RegisterService ¶
func RegisterService(cfg ServiceConfig) error
RegisterService installs adder as a system service using the platform-specific mechanism (systemd user unit, launchd plist, or Windows Task Scheduler).
func StartService ¶
func StartService() error
StartService starts the adder system service using the platform-specific mechanism.
func StopService ¶
func StopService() error
StopService stops the adder system service using the platform-specific mechanism.
func UnregisterService ¶
func UnregisterService() error
UnregisterService removes the adder system service.
func ValidateTemplateParam ¶
ValidateTemplateParam checks if the given parameter (or list of parameters) is valid for the selected template.
Types ¶
type AppBinaryFinder ¶
type AppBinaryFinder struct {
// DevLookup, when true, lets Find() fall back to the current working
// directory (development/debug mode). It defaults to false and is never
// set by production code, so shipped builds never resolve a binary from an
// attacker-influenceable CWD.
//
// A build tag (//go:build dev) would compile the fallback out of release
// binaries entirely — a stronger guarantee — but a struct field is used
// here so the dev path stays exercisable under the standard `go test`
// run. The guarantee therefore rests on no production caller ever setting
// this true; keep it that way.
DevLookup bool
}
AppBinaryFinder locates a trusted `adder` binary to register and run as a system service. The resolved path is embedded into the OS service definition (systemd ExecStart, launchd ProgramArguments, schtasks /TR) and executed, so resolution must never trust an attacker-influenceable location.
func (*AppBinaryFinder) Find ¶
func (f *AppBinaryFinder) Find() (string, error)
type AppConfig ¶
type AppConfig struct {
AutoStart bool
}
AppConfig defines tray-specific application settings.
type BinaryFinder ¶
BinaryFinder defines the interface for locating the adder binary.
type ConfigStore ¶
type ConfigStore interface {
LoadEngine(path string) (config.Config, error)
SaveEngineAtomic(path string, cfg config.Config) error
LoadTray() (TrayConfig, error)
SaveTrayAtomic(cfg TrayConfig) error
}
ConfigStore defines the interface for persisting engine and tray configurations.
type Connector ¶
type Connector interface {
Connect() error
Disconnect()
Reconnect() error
SetAddress(addr string)
SetPort(port uint)
}
Connector defines the interface for managing the API connection.
type FilterConfig ¶
type FilterConfig struct {
Template string // Watch Wallet, Track DRep, Monitor Pool, Monitor Everything
Param string // Comma-separated list of IDs
}
FilterConfig defines the monitoring template and its parameters.
type LocalStore ¶
type LocalStore struct {
TrayConfigPath string
}
LocalStore implements ConfigStore using the local filesystem.
func (*LocalStore) LoadEngine ¶
func (s *LocalStore) LoadEngine(path string) (config.Config, error)
func (*LocalStore) LoadTray ¶
func (s *LocalStore) LoadTray() (TrayConfig, error)
func (*LocalStore) SaveEngineAtomic ¶
func (s *LocalStore) SaveEngineAtomic(path string, cfg config.Config) error
func (*LocalStore) SaveTrayAtomic ¶
func (s *LocalStore) SaveTrayAtomic(cfg TrayConfig) error
type NetworkConfig ¶
type NetworkConfig struct {
Name string // mainnet, preprod, preview
CustomAddress string // For custom node connections
CustomPort uint
}
NetworkConfig defines the Cardano network settings.
type NotificationPrefs ¶
NotificationPrefs defines the user's desktop alert preferences.
type OSManager ¶
type OSManager struct{}
OSManager implements ServiceManager by delegating to platform-specific logic, ensuring operations are idempotent.
func (*OSManager) EnsureRegistered ¶
func (*OSManager) EnsureRunning ¶
func (*OSManager) RestartIfConfigChanged ¶
func (*OSManager) Status ¶
func (m *OSManager) Status() (ServiceStatus, error)
type OutputConfig ¶
type OutputConfig struct {
Type string // none, log, webhook, telegram
Config map[string]string // Key-value pairs for plugin options
}
OutputConfig defines the external event destination.
type ServiceConfig ¶
type ServiceConfig struct {
// BinaryPath is the absolute path to the adder binary.
BinaryPath string
// ConfigPath is the optional path to the adder configuration file.
ConfigPath string
// LogDir is the directory for log output (used by platforms that
// do not support journal-style logging).
LogDir string
}
ServiceConfig holds the configuration needed for service registration.
func (ServiceConfig) Validate ¶
func (c ServiceConfig) Validate() error
Validate checks that the ServiceConfig contains the minimum required fields.
type ServiceManager ¶
type ServiceManager interface {
EnsureRegistered(binPath, cfgPath string) error
EnsureRunning() error
RestartIfConfigChanged(binPath, cfgPath string) error
Stop() error
Status() (ServiceStatus, error)
}
ServiceManager defines the interface for idempotent service lifecycle management.
type ServiceStatus ¶
type ServiceStatus int
ServiceStatus represents the state of the system service.
const ( // ServiceNotRegistered indicates no service is installed. ServiceNotRegistered ServiceStatus = iota // ServiceRegistered indicates the service is installed but not running. ServiceRegistered // ServiceRunning indicates the service is installed and currently running. ServiceRunning )
func ServiceStatusCheck ¶
func ServiceStatusCheck() (ServiceStatus, error)
ServiceStatusCheck returns the current status of the adder system service.
func (ServiceStatus) String ¶
func (s ServiceStatus) String() string
String returns a human-readable representation of the ServiceStatus.
type SetupPlan ¶
type SetupPlan struct {
Network NetworkConfig
Filter FilterConfig
Output OutputConfig
API APIConfig
Notify NotificationPrefs
App AppConfig
}
SetupPlan represents the desired configuration state of the Adder ecosystem, decoupled from UI display strings and engine-specific map structures.
func SetupPlanFromEngineConfig ¶
func SetupPlanFromEngineConfig(c config.Config, tray TrayConfig) SetupPlan
SetupPlanFromEngineConfig reconstructs a SetupPlan from an existing engine configuration and tray settings.
type SetupRunner ¶
type SetupRunner struct {
Store ConfigStore
Service ServiceManager
Conn Connector
Finder BinaryFinder
}
SetupRunner orchestrates the application of a SetupPlan.
type TrayConfig ¶
type TrayConfig struct {
APIAddress string `yaml:"api_address"`
APIPort uint `yaml:"api_port"`
AdderConfig string `yaml:"adder_config"`
AutoStart bool `yaml:"auto_start"`
NotifyPrefs map[string]bool `yaml:"notify_prefs"`
}
TrayConfig holds the configuration for the adder-tray application.