2020-12-16 15:29:12 +08:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
import sys
|
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
import toml
|
2021-06-08 08:26:26 +08:00
|
|
|
|
2020-12-16 15:29:12 +08:00
|
|
|
from rfc2317 import gen_reverse_pointers
|
|
|
|
|
|
|
|
RESOLVE_FILE = Path("dns", "db.10.127")
|
|
|
|
RFC2317_FILE = Path("dns", "rfc2317.toml")
|
|
|
|
|
2021-06-08 08:26:26 +08:00
|
|
|
|
2020-12-16 15:29:12 +08:00
|
|
|
def iter_rfc2317_entry():
|
|
|
|
entries = toml.loads(RFC2317_FILE.read_text())
|
|
|
|
for (route, attributes) in entries.items():
|
2021-06-08 08:26:26 +08:00
|
|
|
ns = attributes.get("NS")
|
|
|
|
ds = attributes.get("DS", list())
|
|
|
|
ttl = attributes.get("TTL", -1)
|
|
|
|
yield (route, ns, ds, ttl)
|
|
|
|
|
2020-12-16 15:29:12 +08:00
|
|
|
|
|
|
|
def main():
|
|
|
|
orignal = RESOLVE_FILE.read_text()
|
|
|
|
records = [orignal, "; AUTOGENERATED"]
|
|
|
|
records.extend(("", "; rfc2317"))
|
2021-04-14 20:15:56 +08:00
|
|
|
for route, ns, ds, ttl in iter_rfc2317_entry():
|
|
|
|
records.extend(gen_reverse_pointers(route, ns, ds, ttl))
|
2020-12-16 15:29:12 +08:00
|
|
|
records.append("")
|
|
|
|
|
|
|
|
RESOLVE_FILE.write_text("\n".join(records))
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|