From: Michael Tremer Date: Tue, 16 Dec 2025 17:24:20 +0000 (+0000) Subject: export: Support exporting a zone with all bogons X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fecf7cce8f91c6dc5509a3153ab981bba696fb45;p=location%2Flibloc.git export: Support exporting a zone with all bogons Signed-off-by: Michael Tremer --- diff --git a/src/python/location/export.py b/src/python/location/export.py index ac41f82..faf39e2 100644 --- a/src/python/location/export.py +++ b/src/python/location/export.py @@ -304,6 +304,7 @@ class Exporter(object): class ZoneExporter(object): def __init__(self, db, format, origin, ttl=None): self.db = db + self.format = format self.origin = origin self.ttl = ttl @@ -332,8 +333,13 @@ class ZoneExporter(object): if self.ttl: f.write("$TTL %s" % self.ttl) + if self.format == "bogons": + networks = self.db.list_bogons() + else: + networks = self.db.networks + # Write all networks - for network in self.db.networks: + for network in networks: self.write(f, network) def write(self, f, network): @@ -356,6 +362,13 @@ class ZoneExporter(object): f.write("%s IN %s %s\n" % (rp, self.type, content)) + # DNSBL + + def _format_dnsbl(self, network): + return "127.0.0.2" + + # ASN + def _format_asn(self, network): # Skip the network if it does not belong to an AS if network.asn is None: @@ -369,5 +382,6 @@ class ZoneExporter(object): return "\"%s\"" % asn formats = { - "asn" : ("TXT", _format_asn), + "asn" : ("TXT", _format_asn), + "bogons" : ("A", _format_dnsbl), }