mirror of
https://gitlab.com/pnx-tools/dns-updater.git
synced 2026-06-16 05:54:56 +02:00
46 lines
867 B
Go
46 lines
867 B
Go
package app
|
|
|
|
import (
|
|
"os"
|
|
|
|
"gopkg.in/yaml.v3"
|
|
)
|
|
|
|
type (
|
|
DomainRecords map[string]string
|
|
Domain map[string]DomainRecords
|
|
)
|
|
|
|
type DigitalOceanService struct {
|
|
Token string `yaml:"token"`
|
|
Domains map[string]DomainRecords `yaml:"domains"`
|
|
}
|
|
|
|
type Providers struct {
|
|
Token string `yaml:"token"`
|
|
Domains map[string]DomainRecords `yaml:"domains"`
|
|
}
|
|
|
|
type Services struct {
|
|
IPLookup string `yaml:"IPLookup"`
|
|
}
|
|
|
|
type Config struct {
|
|
Services Services `yaml:"services"`
|
|
Providers map[string]map[string]any
|
|
Updates map[string]Domain
|
|
}
|
|
|
|
func LoadConfig(filename string) (*Config, error) {
|
|
cfg := Config{
|
|
Services: Services{
|
|
IPLookup: "ipecho",
|
|
},
|
|
}
|
|
|
|
data, err := os.ReadFile(filename)
|
|
if err == nil {
|
|
err = yaml.Unmarshal(data, &cfg)
|
|
}
|
|
return &cfg, err
|
|
}
|