]> git.ipfire.org Git - location/libloc.git/commitdiff
exporter: Implement exporting AS names over DNS
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 16 Dec 2025 17:48:33 +0000 (17:48 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 16 Dec 2025 17:48:33 +0000 (17:48 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/python/location/export.py

index 6310f7a611f6200d21ca9392494481579bea7b9a..a6ded65e219e857f1c79578e752b5022bc5ccf23 100644 (file)
@@ -336,19 +336,28 @@ class ZoneExporter(object):
                # Write all records
                self.write(self, f)
 
-       def _write_record(self, f, network, type, content):
+       def _write_network(self, f, network, *args, **kwargs):
                """
                        Writes a single record to the output file
                """
                name = network.reverse_pointer(suffix="")
                if name is None:
                        for subnet in network.subnets:
-                               self._write_record(f, subnet, type, content)
+                               self._write_record(f, subnet, *args, **kwargs)
 
                        return
 
+               self._write_record(f, network, *args, **kwargs)
+
+       def _write_record(self, f, name, type, content):
                f.write("%s IN %s %s\n" % (name, type, content))
 
+       # ASN
+
+       def _write_asn(self, f):
+               for asn in self.db.ases:
+                       self._write_record(f, asn.number, "TXT", "\"%s\"" % asn.name)
+
        # Bogons
 
        def _write_bogons(self, f):
@@ -384,6 +393,7 @@ class ZoneExporter(object):
                self._write_record(f, network, "TXT", "\"%s\"" % asn)
 
        formats = {
+               "asn"    : _write_asn,
                "bogons" : _write_bogons,
                "origin" : _write_origin,
        }