You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gdns/config.go

34 lines
654 B
Go

package main
import (
"os"
"github.com/go-yaml/yaml"
)
type conf struct {
UpstreamServers []string `yaml:"upstream_servers"`
BootstrapServers []string `yaml:"bootstrap_servers"`
Listen []listen `yaml:"listen"`
UpstreamTimeout int `yaml:"upstream_timeout"`
UpstreamInsecure bool `yaml:"upstream_insecure"`
}
type listen struct {
Addr string `yaml:"addr"`
Cert string `yaml:"cert"`
Key string `yaml:"key"`
}
func loadConfig(f string) (*conf, error) {
data, err := os.ReadFile(f)
if err != nil {
return nil, err
}
var c conf
if err := yaml.Unmarshal(data, &c); err != nil {
return nil, err
}
return &c, nil
}