From 226855c5f26de67e3fd52cdb49b72e26d529bf23 Mon Sep 17 00:00:00 2001 From: Jerry Date: Tue, 8 Jun 2021 08:53:11 +0800 Subject: [PATCH] dns: add DNSKEY to db --- scripts/dns-generator.py | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/scripts/dns-generator.py b/scripts/dns-generator.py index 62ae0dd..95e41c9 100755 --- a/scripts/dns-generator.py +++ b/scripts/dns-generator.py @@ -4,9 +4,14 @@ from pathlib import Path import toml -from rfc2317 import gen_reverse_pointers +from rfc2317 import gen_reverse_pointers, ZONE as RFC2317_ZONE +from roa import export_dnssec_dnskey -RESOLVE_FILE = Path("dns", "db.10.127") +ZONE_FILE_MAP = { + 'neo.': Path("dns", "neonetwork"), + '127.10.in-addr.arpa.': Path("dns", "db.10.127"), + '7.2.1.0.0.1.d.f.ip6.arpa.': Path("dns", "db.fd10.127") +} RFC2317_FILE = Path("dns", "rfc2317.toml") @@ -20,14 +25,20 @@ def iter_rfc2317_entry(): def main(): - orignal = RESOLVE_FILE.read_text() - records = [orignal, "; AUTOGENERATED"] - records.extend(("", "; rfc2317")) - for route, ns, ds, ttl in iter_rfc2317_entry(): - records.extend(gen_reverse_pointers(route, ns, ds, ttl)) + DNSKEYS = {entry['zone']: entry['records'] for entry in export_dnssec_dnskey()} + for zone, zone_file in ZONE_FILE_MAP.items(): + orignal = zone_file.read_text() + records = [orignal, "; AUTOGENERATED"] + if zone.strip('.') == RFC2317_ZONE.strip('.'): + records.extend(("", "; rfc2317")) + for route, ns, ds, ttl in iter_rfc2317_entry(): + records.extend(gen_reverse_pointers(route, ns, ds, ttl)) + records.append("") + records.extend(("", "; dnskey")) + for key_ds in DNSKEYS[zone]: + records.append(f"@ IN DNSKEY {key_ds['dnskey']}") records.append("") - - RESOLVE_FILE.write_text("\n".join(records)) + zone_file.write_text("\n".join(records)) if __name__ == "__main__":