diff options
| author | Shulhan <ms@kilabit.info> | 2022-08-03 23:25:35 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2022-08-03 23:40:22 +0700 |
| commit | fcde3db519e5e560201f1acc7bb3139e0aa66c34 (patch) | |
| tree | 564cc4c110db505d010358b4e3af539a87f75165 | |
| parent | 9436c1361bb3bf3951fe0b14720cb68fcd1a4aaa (diff) | |
| download | pakakeh.go-fcde3db519e5e560201f1acc7bb3139e0aa66c34.tar.xz | |
lib/dns: add field SOA to the ServerOptions
The SOA field defined the root authority for all zones and records
served under the Server.
| -rw-r--r-- | lib/dns/server_options.go | 5 | ||||
| -rw-r--r-- | lib/dns/server_options_test.go | 11 |
2 files changed, 15 insertions, 1 deletions
diff --git a/lib/dns/server_options.go b/lib/dns/server_options.go index b400c24e..94581438 100644 --- a/lib/dns/server_options.go +++ b/lib/dns/server_options.go @@ -62,6 +62,9 @@ type ServerOptions struct { // NameServers []string `ini:"dns:server:parent"` + // The root authority for all zones and records under this server. + SOA RDataSOA + // HTTPIdleTimeout number of seconds before considering the client of // HTTP connection to be closed. // This field is optional, default to 120 seconds. @@ -107,6 +110,8 @@ type ServerOptions struct { // init initialize the server options. func (opts *ServerOptions) init() (err error) { + opts.SOA.init() + if len(opts.ListenAddress) == 0 { opts.ListenAddress = "0.0.0.0:53" } diff --git a/lib/dns/server_options_test.go b/lib/dns/server_options_test.go index 6db8e9cc..25758740 100644 --- a/lib/dns/server_options_test.go +++ b/lib/dns/server_options_test.go @@ -21,7 +21,14 @@ func TestServerOptionsInit(t *testing.T) { } var ( - ip net.IP = net.ParseIP("0.0.0.0") + ip net.IP = net.ParseIP("0.0.0.0") + defSoa = RDataSOA{ + RName: defaultRName, + Serial: uint32(time.Now().Unix()), + Refresh: defaultRefresh, + Retry: defaultRetry, + Minimum: defaultMinimumTTL, + } cases []testCase c testCase @@ -34,6 +41,7 @@ func TestServerOptionsInit(t *testing.T) { exp: &ServerOptions{ ListenAddress: "0.0.0.0:53", HTTPIdleTimeout: defaultHTTPIdleTimeout, + SOA: defSoa, PruneDelay: time.Hour, PruneThreshold: -1 * time.Hour, ip: ip, @@ -66,6 +74,7 @@ func TestServerOptionsInit(t *testing.T) { NameServers: []string{ "udp://127.0.0.1", }, + SOA: defSoa, PruneDelay: time.Hour, PruneThreshold: -1 * time.Hour, ip: ip, |
