From: Michael Tremer Date: Sat, 6 Dec 2025 19:30:02 +0000 (+0000) Subject: dnsbl: Add a header to all exports X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e5b87285349a66b30b5ebd481c30c077a01b49c4;p=dbl.git dnsbl: Add a header to all exports Signed-off-by: Michael Tremer --- diff --git a/src/dnsbl/lists.py b/src/dnsbl/lists.py index 887053d..b2c94e7 100644 --- a/src/dnsbl/lists.py +++ b/src/dnsbl/lists.py @@ -232,11 +232,18 @@ class List(sqlmodel.SQLModel, database.BackendMixin, table=True): # 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, @@ -263,3 +270,41 @@ class List(sqlmodel.SQLModel, database.BackendMixin, table=True): # 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))