2023-02-02 10:55:24 +01:00
|
|
|
package config
|
|
|
|
|
2023-03-24 23:17:55 +01:00
|
|
|
import "forge.cadoles.com/Cadoles/emissary/internal/agent/controller/openwrt"
|
|
|
|
|
2023-02-02 10:55:24 +01:00
|
|
|
type AgentConfig struct {
|
2023-03-02 13:05:24 +01:00
|
|
|
ServerURL InterpolatedString `yaml:"serverUrl"`
|
|
|
|
PrivateKeyPath InterpolatedString `yaml:"privateKeyPath"`
|
|
|
|
ReconciliationInterval InterpolatedInt `yaml:"reconciliationInterval"`
|
|
|
|
Controllers ControllersConfig `yaml:"controllers"`
|
|
|
|
Collectors []ShellCollectorConfig `yaml:"collectors"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type ShellCollectorConfig struct {
|
|
|
|
Name InterpolatedString `yaml:"name"`
|
|
|
|
Command InterpolatedString `yaml:"command"`
|
|
|
|
Args InterpolatedStringSlice `yaml:"args"`
|
2023-02-02 10:55:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
type ControllersConfig struct {
|
|
|
|
Persistence PersistenceControllerConfig `yaml:"persistence"`
|
|
|
|
Spec SpecControllerConfig `yaml:"spec"`
|
2023-03-21 13:28:41 +01:00
|
|
|
Proxy ProxyControllerConfig `yaml:"proxy"`
|
2023-02-02 10:55:24 +01:00
|
|
|
UCI UCIControllerConfig `yaml:"uci"`
|
2023-03-03 20:37:09 +01:00
|
|
|
App AppControllerConfig `yaml:"app"`
|
2023-03-24 23:17:55 +01:00
|
|
|
SysUpgrade SysUpgradeControllerConfig `yaml:"sysupgrade"`
|
2023-04-04 20:26:19 +02:00
|
|
|
MDNS MDNSControllerConfig `yaml:"mdns"`
|
2024-02-29 17:17:21 +01:00
|
|
|
Status StatusControllerConfig `yaml:"status"`
|
2023-02-02 10:55:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
type PersistenceControllerConfig struct {
|
|
|
|
Enabled InterpolatedBool `yaml:"enabled"`
|
|
|
|
StateFile InterpolatedString `yaml:"stateFile"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type SpecControllerConfig struct {
|
2023-03-02 13:05:24 +01:00
|
|
|
Enabled InterpolatedBool `yaml:"enabled"`
|
2023-02-02 10:55:24 +01:00
|
|
|
}
|
2023-03-21 13:28:41 +01:00
|
|
|
type ProxyControllerConfig struct {
|
2023-02-02 10:55:24 +01:00
|
|
|
Enabled InterpolatedBool `yaml:"enabled"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type UCIControllerConfig struct {
|
|
|
|
Enabled InterpolatedBool `yaml:"enabled"`
|
|
|
|
BinPath InterpolatedString `yaml:"binPath"`
|
|
|
|
ConfigBackupFile InterpolatedString `yaml:"configBackupFile"`
|
|
|
|
}
|
|
|
|
|
2023-03-03 20:37:09 +01:00
|
|
|
type AppControllerConfig struct {
|
|
|
|
Enabled InterpolatedBool `yaml:"enabled"`
|
|
|
|
DataDir InterpolatedString `yaml:"dataDir"`
|
|
|
|
DownloadDir InterpolatedString `yaml:"downloadDir"`
|
|
|
|
}
|
|
|
|
|
2023-03-24 23:17:55 +01:00
|
|
|
type SysUpgradeControllerConfig struct {
|
|
|
|
Enabled InterpolatedBool `yaml:"enabled"`
|
|
|
|
SysUpgradeCommand InterpolatedStringSlice `yaml:"sysupgradeCommand"`
|
|
|
|
FirmwareVersionCommand InterpolatedStringSlice `yaml:"firmwareVersionCommand"`
|
|
|
|
}
|
|
|
|
|
2023-04-04 20:26:19 +02:00
|
|
|
type MDNSControllerConfig struct {
|
|
|
|
Enabled InterpolatedBool `yaml:"enabled"`
|
|
|
|
}
|
|
|
|
|
2024-02-29 17:17:21 +01:00
|
|
|
type StatusControllerConfig struct {
|
|
|
|
Enabled InterpolatedBool `yaml:"enabled"`
|
|
|
|
Address InterpolatedString `yaml:"address"`
|
|
|
|
ClaimURL InterpolatedString `yaml:"claimURL"`
|
|
|
|
AgentURL InterpolatedString `yaml:"agentURL"`
|
|
|
|
}
|
|
|
|
|
2023-02-02 10:55:24 +01:00
|
|
|
func NewDefaultAgentConfig() AgentConfig {
|
|
|
|
return AgentConfig{
|
2023-03-02 13:05:24 +01:00
|
|
|
ServerURL: "http://127.0.0.1:3000",
|
|
|
|
PrivateKeyPath: "agent-key.json",
|
2023-02-02 10:55:24 +01:00
|
|
|
ReconciliationInterval: 5,
|
|
|
|
Controllers: ControllersConfig{
|
|
|
|
Spec: SpecControllerConfig{
|
2023-03-02 13:05:24 +01:00
|
|
|
Enabled: true,
|
2023-02-02 10:55:24 +01:00
|
|
|
},
|
|
|
|
Persistence: PersistenceControllerConfig{
|
|
|
|
Enabled: true,
|
|
|
|
StateFile: "state.json",
|
|
|
|
},
|
2023-03-21 13:28:41 +01:00
|
|
|
Proxy: ProxyControllerConfig{
|
2023-02-02 10:55:24 +01:00
|
|
|
Enabled: true,
|
|
|
|
},
|
|
|
|
UCI: UCIControllerConfig{
|
|
|
|
Enabled: true,
|
|
|
|
ConfigBackupFile: "uci-backup.conf",
|
|
|
|
BinPath: "uci",
|
|
|
|
},
|
2023-03-03 20:37:09 +01:00
|
|
|
App: AppControllerConfig{
|
|
|
|
Enabled: true,
|
|
|
|
DataDir: "apps/data",
|
|
|
|
DownloadDir: "apps/bundles",
|
|
|
|
},
|
2023-03-24 23:17:55 +01:00
|
|
|
SysUpgrade: SysUpgradeControllerConfig{
|
|
|
|
Enabled: true,
|
|
|
|
SysUpgradeCommand: InterpolatedStringSlice{"sysupgrade", "--force", "-u", "-v", openwrt.FirmwareFileTemplate},
|
|
|
|
FirmwareVersionCommand: InterpolatedStringSlice{"sh", "-c", `source /etc/openwrt_release && echo "$DISTRIB_ID-$DISTRIB_RELEASE-$DISTRIB_REVISION"`},
|
|
|
|
},
|
2023-04-04 20:26:19 +02:00
|
|
|
MDNS: MDNSControllerConfig{
|
|
|
|
Enabled: true,
|
|
|
|
},
|
2024-02-29 17:17:21 +01:00
|
|
|
Status: StatusControllerConfig{
|
|
|
|
Enabled: true,
|
|
|
|
Address: ":42521",
|
|
|
|
ClaimURL: "http://localhost:3001/claim/%s",
|
|
|
|
AgentURL: "http://localhost:3001/agents/%v",
|
|
|
|
},
|
2023-02-02 10:55:24 +01:00
|
|
|
},
|
2023-03-02 13:05:24 +01:00
|
|
|
Collectors: []ShellCollectorConfig{
|
|
|
|
{
|
|
|
|
Name: "uname",
|
|
|
|
Command: "uname",
|
|
|
|
Args: []string{"-a"},
|
|
|
|
},
|
|
|
|
},
|
2023-02-02 10:55:24 +01:00
|
|
|
}
|
|
|
|
}
|