-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
37 lines (29 loc) · 975 Bytes
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package main
import (
"io/ioutil"
"gopkg.in/yaml.v2"
)
type Config struct {
Checks map[string]CheckConfig `json:"checks" yaml:"checks"`
}
type CheckConfig struct {
Resolver string `yaml:"resolver" json:"resolver"`
ResolverTimeout string `yaml:"resolver_timeout" json:"resolver_timeout"`
UseTCP bool `yaml:"use_tcp" json:"use_tcp"`
Resolve string `yaml:"resolve" json:"resolve"`
Expect ExpectConfig `yaml:"expect" json:"expect"`
}
type ExpectConfig struct {
AnswerSection []string `yaml:"answer_section" json:"answer_section"`
AuthoritySection []string `yaml:"authority_section" json:"authority_section"`
AdditionalSection []string `yaml:"additional_section" json:"additional_section"`
}
func NewConfig(path string) (*Config, error) {
config := Config{}
data, err := ioutil.ReadFile(path)
if err != nil {
return &config, err
}
err = yaml.Unmarshal(data, &config)
return &config, err
}