###############################################################################
import abc
+import datetime
import dns.name
import dns.rdataclass
import dns.zone
"""
Writes a header
"""
+ now = datetime.datetime.now()
+
lines = [
"##############################################################################",
" DNS Blocklist for IPFire",
"",
]
+ # Add the license
lines += [
" License : %s" % self.list.license,
- " Updated : %s" % self.list.updated_at.isoformat(),
+ ]
+
+ # Add the update timestamp
+ if self.list.updated_at:
+ lines += [
+ " Updated : %s" % self.list.updated_at.isoformat(),
+ ]
+
+ lines += [
"",
- " Copyright (C) %s - IPFire Team" % self.list.updated_at.strftime("%Y"),
+ " Copyright (C) %s - IPFire Team" % now.strftime("%Y"),
"",
" For more information or to contribute:",
" https://dnsbl.ipfire.org/",
zone = dns.zone.Zone(origin)
# Make the serial
- serial = self.list.updated_at.strftime("%s")
+ if self.list.updated_at:
+ serial = self.list.updated_at.strftime("%s")
+ else:
+ serial = "0"
# Create the SOA
soa = dns.rdataset.from_text(
file.size = f.tell()
# Set the mtime
- file.mtime = list.updated_at.timestamp()
+ if self.list.updated_at:
+ file.mtime = self.list.updated_at.timestamp()
# Reset the buffer
f.seek(0)
# Set the modification time (so that clients won't download again
# just because we have done a re-export)
- os.utime(f.name, (list.updated_at.timestamp(), list.updated_at.timestamp()))
+ if list.updated_at:
+ os.utime(f.name, (
+ list.updated_at.timestamp(),
+ list.updated_at.timestamp(),
+ ))
# Fix permissions
os.chmod(f.name, 0o644)