-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.go
44 lines (36 loc) · 859 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
38
39
40
41
42
43
44
package main
import (
"encoding/json"
"os"
)
type conf struct {
Ns []string
AxfrWhitelistedZones []string
AxfrWhitelistedIPs []string
SplitSize int
}
var (
usedNs []string
usedNsLen int
AxfrWhitelistedZoneSet = make(Set[string])
AxfrWhitelistedIPSet = make(Set[string])
splitSize int
)
var globalConf conf
// read config and populate global variables
func readConfig() {
b := check1(os.ReadFile("conf.json"))
check(json.Unmarshal(b, &globalConf))
usedNs = globalConf.Ns
usedNsLen = len(usedNs)
splitSize = globalConf.SplitSize
if globalConf.SplitSize == 0 {
splitSize = 2
}
for _, zone := range globalConf.AxfrWhitelistedZones {
AxfrWhitelistedZoneSet.Add(zone)
}
for _, ip := range globalConf.AxfrWhitelistedIPs {
AxfrWhitelistedIPSet.Add(ip)
}
}