From fcde3db519e5e560201f1acc7bb3139e0aa66c34 Mon Sep 17 00:00:00 2001 From: Shulhan Date: Wed, 3 Aug 2022 23:25:35 +0700 Subject: lib/dns: add field SOA to the ServerOptions The SOA field defined the root authority for all zones and records served under the Server. --- lib/dns/server_options.go | 5 +++++ lib/dns/server_options_test.go | 11 ++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) 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, -- cgit v1.3