# Create a new zone
zone = dns.zone.Zone(origin)
+ # Make the serial
+ serial = self.list.updated_at.strftime("%s")
+
# Create the SOA
soa = dns.rdataset.from_text(
dns.rdataclass.IN,
" ".join((
"master.lwldns.net.",
"hostmaster.ipfire.org.",
- self.list.updated_at.strftime("%s"),
+ serial,
"3600",
"600",
"3600000",
# Write all domains
for domain in self.list.domains:
zone.replace_rdataset(
- dns.name.from_text("%s.%s" % (domain, self.list.zone)),
+ dns.name.from_text("%s.%s" % (domain, self.list.zone), origin=origin),
dns.rdataset.from_text(
dns.rdataclass.IN, dns.rdatatype.CNAME, ttl, rpz_action,
),
)
+ # Add ZONEMD
+ self.add_zonemd(zone, ttl)
+
# Write the zone to file
zone.to_file(f)
+
+ def add_zonemd(self, zone, ttl):
+ """
+ Adds ZONEMD records to the zone
+ """
+ # Create a new ZONEMD record
+ rrset = dns.rdataset.Rdataset(
+ dns.rdataclass.IN, dns.rdatatype.ZONEMD, ttl=ttl,
+ )
+
+ # Compute the digest for SHA-512 and SHA-384
+ algorithms = (
+ dns.zone.DigestHashAlgorithm.SHA512,
+ dns.zone.DigestHashAlgorithm.SHA384,
+ )
+
+ # Compute the digests
+ for algorithm in algorithms:
+ rrset.add(
+ zone.compute_digest(algorithm),
+ )
+
+ # Add the ZONEMD record
+ zone.replace_rdataset(zone.origin, rrset)