# Write the domains as they are
if format == "domains":
+ # Write the header
+ self._write_header(f)
+
+ # Write all domains
for domain in self.domains:
f.write("%s\n" % domain)
# Write a RPZ zone file
elif format == "rpz":
+ # Write the header
+ self._write_header(f, ";")
+
# Write the SOA
f.write("%s\n" % " ".join((
self.zone,
# the underlying file handle.
if detach:
f.detach()
+
+ def _write_header(self, f, delim="#"):
+ """
+ Writes a header
+ """
+ lines = [
+ "##############################################################################",
+ " DNS Blocklist for IPFire",
+ "##############################################################################",
+ "",
+ " This file contains domains that are part of the official IPFire DNS",
+ " Blocklist Project. It is intended for use with DNS servers and firewalls",
+ " that support blocklisting of known malicious or unwanted domains.",
+ "",
+ " List : %s" % self.name,
+ " License : %s" % self.license,
+ " Copyright (C) %s - IPFire Team" % self.updated_at.strftime("%Y"),
+ "",
+ " For more information or to contribute:",
+ " https://dnsbl.ipfire.org/",
+ "",
+ "##############################################################################",
+ "",
+ " This list contains data from these sources:",
+ "",
+ ]
+
+ # Append all sources
+ for source in self.sources:
+ lines.append(" * %s (%s)" % (source.name, source.license))
+ lines.append(" %s" % source.url)
+
+ # Newline
+ lines.append("")
+
+ # Write everything to the output file
+ for line in lines:
+ f.write("%s%s\n" % (delim, line))