From 34d09fcaa210ddd9d8bf8d1754151faeebf4e485 Mon Sep 17 00:00:00 2001 From: Shulhan Date: Sat, 5 Aug 2023 15:21:29 +0700 Subject: lib/dns: always initialize the Zone SOA record to default values Previously, if we parse, create, or remove the SOA record from zone, we assume the SOA records are valid and not touch their values. In this changes, we set the SOA fields to default values if its not set, to make the SOA record consistent and valid, in perspective of client. This changes also export the default OS values for documentation and add new method NewRDataSOA to simplify creating new SOA record. --- lib/dns/dns_test.go | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'lib/dns/dns_test.go') diff --git a/lib/dns/dns_test.go b/lib/dns/dns_test.go index 1d9bac6a..207b5a3c 100644 --- a/lib/dns/dns_test.go +++ b/lib/dns/dns_test.go @@ -15,6 +15,9 @@ const ( testServerAddress = "127.0.0.1:5300" testDoTServerAddress = "127.0.0.1:18053" testTLSPort = 18053 + + // Equal to 2023-08-05 07:53:20 +0000 UTC. + testNowEpoch = 1691222000 ) var ( @@ -24,6 +27,10 @@ var ( func TestMain(m *testing.M) { log.SetFlags(0) + timeNow = func() time.Time { + return time.Unix(testNowEpoch, 0) + } + var ( serverOptions = &ServerOptions{ ListenAddress: "127.0.0.1:5300", -- cgit v1.3