mirror of
https://github.com/NeoCloud/NeoNetwork
synced 2024-11-22 18:00:41 +08:00
31 lines
839 B
Python
Executable file
31 lines
839 B
Python
Executable file
#!/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')
|
|
ds = attributes.get('DS', list())
|
|
ttl = attributes.get('TTL', -1)
|
|
yield(route, ns, ds, ttl)
|
|
|
|
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))
|
|
records.append("")
|
|
|
|
RESOLVE_FILE.write_text("\n".join(records))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|