-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.go
More file actions
48 lines (39 loc) · 951 Bytes
/
config.go
File metadata and controls
48 lines (39 loc) · 951 Bytes
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
38
39
40
41
42
43
44
45
46
47
48
package main
import (
"encoding/json"
"os"
"github.com/monoidic/dns"
)
type conf struct {
Ns []string
AxfrWhitelistedZones []string
AxfrWhitelistedIPs []string
Retries int
}
var (
usedNs []string
usedNsLen int
AxfrWhitelistedZoneSet = make(Set[dns.Name])
AxfrWhitelistedIPSet = make(Set[string])
)
func mustParseName(s string) dns.Name {
return check1(dns.NameFromString(s))
}
// read config and populate global variables
func readConfig() {
var globalConf conf
b := check1(os.ReadFile("conf.json"))
check(json.Unmarshal(b, &globalConf))
usedNs = globalConf.Ns
retries = globalConf.Retries
if retries == 0 {
retries = 10
}
usedNsLen = len(usedNs)
for _, zone := range globalConf.AxfrWhitelistedZones {
AxfrWhitelistedZoneSet.Add(mustParseName(zone).Canonical())
}
for _, ip := range globalConf.AxfrWhitelistedIPs {
AxfrWhitelistedIPSet.Add(ip)
}
}