1
0
Fork 0
mirror of https://github.com/NeoCloud/NeoNetwork synced 2024-11-18 11:40:43 +08:00
NeoNetwork/scripts/dns-generator.py

30 lines
730 B
Python
Raw Normal View History

#!/usr/bin/env python3
import sys
from pathlib import Path
import toml
from rfc2317 import gen_reverse_pointers
RESOLVE_FILE = Path("dns", "db.10.127")
RFC2317_FILE = Path("dns", "rfc2317.toml")
def iter_rfc2317_entry():
entries = toml.loads(RFC2317_FILE.read_text())
for (route, attributes) in entries.items():
ns = attributes.get('ns')
yield(route, ns)
def main():
orignal = RESOLVE_FILE.read_text()
records = [orignal, "; AUTOGENERATED"]
records.extend(("", "; rfc2317"))
for route, ns in iter_rfc2317_entry():
records.extend(gen_reverse_pointers(route, ns))
records.append("")
RESOLVE_FILE.write_text("\n".join(records))
if __name__ == "__main__":
main()