Change the default serial.

This commit is contained in:
Philippe PITTOLI 2024-07-07 11:40:18 +02:00
parent b633dbe740
commit 38da24fe66
2 changed files with 26 additions and 0 deletions

View File

@ -149,6 +149,12 @@ class DNSManager::Storage
# Replace domain by the real domain.
default_zone.replace_domain domain
# Reset the serial number so it represents the current date.
# This is particularly useful when a zone is deleted then re-used again right after, in this case
# the serial would be a problem since the new zone may not be usable for some time, depending on the
# configuration.
default_zone.reset_serial
#
# Actually write data on-disk.
#

View File

@ -120,6 +120,16 @@ class DNSManager::Storage::Zone
@rrtype = "SOA"
end
# Sets the serial number to the current date.
def reset_serial
t = Time.local
y = t.year
m = t.month
d = t.day
@serial = "#{y}#{ "%0.2d" % m}#{ "%0.2d" % d}00".to_u64
end
def to_s(io : IO)
io << "(#{ "%4d" % @rrid }) "
io << "#{name} #{ttl} SOA (#{mname} #{rname}\n"
@ -1009,6 +1019,16 @@ class DNSManager::Storage::Zone
false
end
# Selects the SOA entry then run the `reset_serial` procedure.
def reset_serial
@resources.each do |rr|
case rr
when SOA
rr.reset_serial
end
end
end
# When a new domain is recorded, we load a template which contains a placeholder domain.
# `replace_domain` replaces this domain name by the real one in the different (preloaded) RR.
# Do not forget the last dot ('.') to get a fully qualified domain name (FQDN).