From c602e2fae5dd7dd4982ab2de72a47997e09570d8 Mon Sep 17 00:00:00 2001 From: Jerry Date: Wed, 16 Dec 2020 15:29:12 +0800 Subject: [PATCH] remove legacy reverse pointer generator since it's causing headaches --- dns/db.10.127 | 55 ++++++++++++++++-------------- dns/db.fd10.127 | 5 +++ dns/neonetwork | 4 +++ scripts/dns-generator.py | 29 ++++++++++++++++ scripts/dns-reverse-generator.py | 57 -------------------------------- scripts/generate-roa.sh | 2 +- 6 files changed, 70 insertions(+), 82 deletions(-) create mode 100755 scripts/dns-generator.py delete mode 100755 scripts/dns-reverse-generator.py diff --git a/dns/db.10.127 b/dns/db.10.127 index 7d71644..2259081 100644 --- a/dns/db.10.127 +++ b/dns/db.10.127 @@ -10,19 +10,19 @@ $TTL 604800 @ IN NS NeoPDP-11.neo. ; -1.1 IN PTR NeoPDP-11.neo. -40.1 IN PTR cklvax.neo. -63.1 IN PTR NNPCC.neo. -20.1 IN PTR NeoBOX.neo. -10.1 IN PTR neostorage.neonetwork. -80.1 IN PTR NeoSystem.neo. -1.3 IN PTR pan.neo. -16.2 IN PTR caasih.neo. -127.2 IN PTR NeoRouter.neo. +1.1 IN PTR NeoPDP-11.neo. +40.1 IN PTR cklvax.neo. +63.1 IN PTR NNPCC.neo. +20.1 IN PTR NeoBOX.neo. +10.1 IN PTR neostorage.neonetwork. +80.1 IN PTR NeoSystem.neo. +1.3 IN PTR pan.neo. +16.2 IN PTR caasih.neo. +127.2 IN PTR NeoRouter.neo. 1.233 IN PTR liqingge.user-icecat.eth-ether5.cn.magicneko.neo. 1.234 IN PTR liqingge.user-icecat.eth-ether5.cn.magicneko.neo. -8.4 IN PTR koishi-v4.up-core.vtap-hentai-bb.hk.magicneko.neo. +8.4 IN PTR koishi-v4.up-core.vtap-hentai-bb.hk.magicneko.neo. 10.4 IN PTR luotianyi-v4.up.vtap-hentai-bb.hk.magicneko.neo. 15.4 IN PTR yuezhengling-v4.up.vtap-hentai-bb.jp.magicneko.neo. @@ -30,23 +30,30 @@ $TTL 604800 1.8 IN PTR librehs.neo. 2.8 IN PTR blog.librehs.neo. +; Loopback Addresses + +1.255 IN PTR NeoPDP-11.neo. +4.255 IN PTR pan.neo. +18.255 IN PTR icecat-video.neo. +53.255 IN PTR root-dns.neo. +54.255 IN PTR dns.neo. +56.255 IN PTR frank-hsinchu-1.neo. +80.255 IN PTR NeoSystem.neo. +117.255 IN PTR magicneko-tw.neo. + ; DELEGATED ZONES -9 IN NS ns1.jerry.neo. -12 IN NS ns1.yangfl.dn42. - NS ns2.yangfl.dn42. +7 IN NS ns1.staph.neo. -10 IN NS ns1.lantian.neo. -10 IN NS ns2.lantian.neo. -10 IN NS ns3.lantian.neo. -10 IN NS ns4.lantian.neo. -10 IN NS ns5.lantian.neo. -11 IN NS ns1.sun.dn42. +9 IN NS ns1.jerry.neo. -7 IN NS ns1.staph.neo. +10 IN NS ns1.lantian.neo. +10 IN NS ns2.lantian.neo. +10 IN NS ns3.lantian.neo. +10 IN NS ns4.lantian.neo. +10 IN NS ns5.lantian.neo. +11 IN NS ns1.sun.dn42. -; DO NOT MANUALLY EDIT THE FOLLOWING LINES -; AUTOGENERATED - -; PLACEHOLDER +12 IN NS ns1.yangfl.dn42. +12 IN NS ns2.yangfl.dn42. diff --git a/dns/db.fd10.127 b/dns/db.fd10.127 index 26f8b4a..8e7ec31 100644 --- a/dns/db.fd10.127 +++ b/dns/db.fd10.127 @@ -25,6 +25,11 @@ $TTL 604800 0.1.0.0.4.0.0.0.7.2.1.0.0.1.0.0.0.7.2.1.3.3.2.0 IN PTR luotianyi-v6.up.vtap-hentai-bb.hk.magicneko.neo. 5.1.0.0.4.0.0.0.7.2.1.0.0.1.0.0.0.7.2.1.3.3.2.0 IN PTR yuezhengling-v6.up.vtap-hentai-bb.jp.magicneko.neo. +; Loopback Addresses + +0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.3.5.0.0.f.f.f.f IN PTR root-dns.neo. +0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.3.5.0.0.3.5.0.0 IN PTR dns.neo. + ; DELEGATED ZONES 3.5.0.0 IN NS ns1.jerry.neo. diff --git a/dns/neonetwork b/dns/neonetwork index 9cfe847..3c41110 100644 --- a/dns/neonetwork +++ b/dns/neonetwork @@ -26,6 +26,10 @@ santost12 IN A 10.127.39.1 neko IN TXT "helloworld" telegram IN TXT "https://t.me/NeoNetworkVPN" +root-dns IN A 10.127.255.53 +root-dns IN AAAA fd10:127:ffff:53:: +dns IN A 10.127.255.54 +dns IN AAAA fd10:127:53:53:: ; DELEGATED ZONES jerry IN NS ns1.jerry diff --git a/scripts/dns-generator.py b/scripts/dns-generator.py new file mode 100755 index 0000000..fb468b8 --- /dev/null +++ b/scripts/dns-generator.py @@ -0,0 +1,29 @@ +#!/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() diff --git a/scripts/dns-reverse-generator.py b/scripts/dns-reverse-generator.py deleted file mode 100755 index 8dd3b03..0000000 --- a/scripts/dns-reverse-generator.py +++ /dev/null @@ -1,57 +0,0 @@ -#!/usr/bin/env python3 -import sys -from ipaddress import IPv4Address, ip_network, IPv4Network -from pathlib import Path - -import toml -from rfc2317 import gen_reverse_pointers - -RESOLVE_FILE = Path("dns", "db.10.127") -ROUTE_FILE = Path("route") -RFC2317_FILE = Path("dns", "rfc2317.toml") - -def iter_route(route_type: str): - items = [] - for f in ROUTE_FILE.iterdir(): - routes = toml.loads(f.read_text()) - items.extend( - (entity["name"], ip_network(route).network_address) - for route, entity in routes.items() - if entity["type"] == route_type and isinstance(ip_network(route), IPv4Network) - ) - routes = [] - remove = [] - for item in items[::-1]: - if item[1] in routes: - remove.append(item) - else: - routes.append(item[1]) - for i in remove: - items.remove(i) - return sorted(items, key=lambda item: item[1]) - -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() - orignal = orignal[: orignal.find("\n; AUTOGENERATED")] - records = [orignal, "; AUTOGENERATED", "", "; Loopback Addresses"] - for name, address in iter_route("loopback"): - if isinstance(address, IPv4Address): - pointer = address.reverse_pointer.replace(".127.10.in-addr.arpa", "") - records.append("%s\tIN\tPTR\t%s.neo." % (pointer, name)) - - 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() diff --git a/scripts/generate-roa.sh b/scripts/generate-roa.sh index 251e3ce..ae3d67c 100755 --- a/scripts/generate-roa.sh +++ b/scripts/generate-roa.sh @@ -11,7 +11,7 @@ export MAX_LEN_6=64 mkdir -p generated mkdir -p generated/dns -scripts/dns-reverse-generator.py +scripts/dns-generator.py cp -R dns/* generated/dns scripts/roa.py -m "$MAX_LEN_4" -M "$MAX_LEN_6" -o generated/roa46_bird2.conf