From: Michael Tremer Date: Tue, 16 Dec 2025 17:48:33 +0000 (+0000) Subject: exporter: Implement exporting AS names over DNS X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=86e3adfa3c76ebed2984c19d5fd2030c30a55d88;p=location%2Flibloc.git exporter: Implement exporting AS names over DNS Signed-off-by: Michael Tremer --- diff --git a/src/python/location/export.py b/src/python/location/export.py index 6310f7a..a6ded65 100644 --- a/src/python/location/export.py +++ b/src/python/location/export.py @@ -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, }