aboutsummaryrefslogtreecommitdiff
path: root/lib/dns/dns.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2023-08-05 15:21:29 +0700
committerShulhan <ms@kilabit.info>2023-08-05 15:47:53 +0700
commit34d09fcaa210ddd9d8bf8d1754151faeebf4e485 (patch)
tree7346e07a168f65f81dd5475816bb1e88119f9a0f /lib/dns/dns.go
parentbd2ae82e254e203a021c9907e41b41ec0643ad49 (diff)
downloadpakakeh.go-34d09fcaa210ddd9d8bf8d1754151faeebf4e485.tar.xz
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.
Diffstat (limited to 'lib/dns/dns.go')
-rw-r--r--lib/dns/dns.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/dns/dns.go b/lib/dns/dns.go
index f7a9df17..31bfec8d 100644
--- a/lib/dns/dns.go
+++ b/lib/dns/dns.go
@@ -134,3 +134,9 @@ var rcodeNames = map[ResponseCode]string{
RCodeNotImplemented: "ERR_NOT_IMPLEMENTED",
RCodeRefused: "ERR_REFUSED",
}
+
+// timeNow return the current time.
+// This variable provides to help mocking the test that require time value.
+var timeNow = func() time.Time {
+ return time.Now()
+}