From: Michael Tremer Date: Wed, 31 Dec 2025 16:37:39 +0000 (+0000) Subject: exporter: Support exporting for AdBlock Plus X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cf6f881b73ea5ce58d29a0e2c6c882a216aab704;p=dbl.git exporter: Support exporting for AdBlock Plus Signed-off-by: Michael Tremer --- diff --git a/src/dnsbl/exporters.py b/src/dnsbl/exporters.py index 3387bb1..7408289 100644 --- a/src/dnsbl/exporters.py +++ b/src/dnsbl/exporters.py @@ -151,6 +151,22 @@ class HostsExporter(TextExporter): f.write("0.0.0.0 %s\n" % domain) +class AdBlockPlusExporter(TextExporter): + """ + Exports for AdBlock Plus and compatible clients + """ + def export(self, f): + # Write the format + f.write("[Adblock Plus]\n") + + # Write the header + self.write_header(f, "!") + + # Write all domains + for domain in self.list.domains: + f.write("||%s^\n" % domain) + + class ZoneExporter(TextExporter): def export(self, f, ttl=60): # Write the header diff --git a/src/dnsbl/lists.py b/src/dnsbl/lists.py index 99c29ec..3173b2a 100644 --- a/src/dnsbl/lists.py +++ b/src/dnsbl/lists.py @@ -410,6 +410,7 @@ class List(sqlmodel.SQLModel, database.BackendMixin, table=True): Exports the list """ formats = { + "abp" : exporters.AdBlockPlusExporter, "domains" : exporters.DomainsExporter, "dnsbl" : exporters.BlocklistExporter, "hosts" : exporters.HostsExporter, diff --git a/src/scripts/dnsbl.in b/src/scripts/dnsbl.in index 81fad18..8edcab2 100644 --- a/src/scripts/dnsbl.in +++ b/src/scripts/dnsbl.in @@ -111,7 +111,7 @@ class CLI(object): export.add_argument("output", type=argparse.FileType("wb"), help=_("The output file")) export.add_argument("--format", default="domains", - choices=("domains", "dnsbl", "hosts", "rpz", "squidguard",), + choices=("abp", "domains", "dnsbl", "hosts", "rpz", "squidguard",), help=_("Output Format")) export.set_defaults(func=self.__export) @@ -357,6 +357,7 @@ class CLI(object): Exports all lists """ formats = { + "abp" : "abp.txt", "domains" : "domains.txt", "dnsbl" : "dnsbl.zone", "hosts" : "hosts.txt",