1
0
Fork 0
mirror of https://github.com/NeoCloud/NeoNetwork synced 2024-11-25 22:00:41 +08:00

export dnskeys to neonetwork.json

This commit is contained in:
JerryXiao 2021-04-19 10:28:51 +08:00
parent 49c6fc860c
commit 9b5511b6f4
Signed by: Jerry
GPG key ID: 22618F758B5BE2E5

View file

@ -165,6 +165,25 @@ def prehandle_roa(asn_table: dict, args):
r["prefix"] = r["prefix"].with_prefixlen r["prefix"] = r["prefix"].with_prefixlen
return roa4, roa6 return roa4, roa6
def export_dnssec_dnskey():
dnskey_path = Path("dns") / "dnssec"
dnskeys = list()
for f in dnskey_path.iterdir():
if f.name.endswith(".keys"):
zonekey = {"zone": "", "dnskeys": list()}
records = f.read_text().split("\n")
records = [r.split() for r in records if r]
for zone, _ttl, _in, _dnskey, *dnskey in records:
int(_ttl)
assert _in == "IN" and _dnskey == "DNSKEY"
if not zonekey["zone"]:
zonekey["zone"] = zone
else:
assert zonekey["zone"] == zone
zonekey["dnskeys"].append(" ".join(dnskey))
if zonekey["zone"]:
dnskeys.append(zonekey)
return dnskeys
def make_export(roa4, roa6): def make_export(roa4, roa6):
def modify_entity(entity): def modify_entity(entity):
@ -204,6 +223,7 @@ def make_export(roa4, roa6):
} }
for owner, entity in entities.items() for owner, entity in entities.items()
}, },
"dnssec": export_dnssec_dnskey()
} }
return json.dumps(output, indent=2) return json.dumps(output, indent=2)