1
0
Fork 0
mirror of https://github.com/NeoCloud/NeoNetwork synced 2024-12-26 10:59:24 +08:00

remove legacy reverse pointer generator since it's causing headaches

This commit is contained in:
JerryXiao 2020-12-16 15:29:12 +08:00
parent da2c3488db
commit c602e2fae5
Signed by: Jerry
GPG key ID: 9D9CE43650FF2BAA
6 changed files with 70 additions and 82 deletions

View file

@ -30,23 +30,30 @@ $TTL 604800
1.8 IN PTR librehs.neo. 1.8 IN PTR librehs.neo.
2.8 IN PTR blog.librehs.neo. 2.8 IN PTR blog.librehs.neo.
; DELEGATED ZONES ; Loopback Addresses
9 IN NS ns1.jerry.neo.
12 IN NS ns1.yangfl.dn42. 1.255 IN PTR NeoPDP-11.neo.
NS ns2.yangfl.dn42. 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
7 IN NS ns1.staph.neo.
9 IN NS ns1.jerry.neo.
10 IN NS ns1.lantian.neo. 10 IN NS ns1.lantian.neo.
10 IN NS ns2.lantian.neo. 10 IN NS ns2.lantian.neo.
10 IN NS ns3.lantian.neo. 10 IN NS ns3.lantian.neo.
10 IN NS ns4.lantian.neo. 10 IN NS ns4.lantian.neo.
10 IN NS ns5.lantian.neo. 10 IN NS ns5.lantian.neo.
11 IN NS ns1.sun.dn42. 11 IN NS ns1.sun.dn42.
7 IN NS ns1.staph.neo. 12 IN NS ns1.yangfl.dn42.
12 IN NS ns2.yangfl.dn42.
; DO NOT MANUALLY EDIT THE FOLLOWING LINES
; AUTOGENERATED
; PLACEHOLDER

View file

@ -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. 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. 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 ; DELEGATED ZONES
3.5.0.0 IN NS ns1.jerry.neo. 3.5.0.0 IN NS ns1.jerry.neo.

View file

@ -26,6 +26,10 @@ santost12 IN A 10.127.39.1
neko IN TXT "helloworld" neko IN TXT "helloworld"
telegram IN TXT "https://t.me/NeoNetworkVPN" 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 ; DELEGATED ZONES
jerry IN NS ns1.jerry jerry IN NS ns1.jerry

29
scripts/dns-generator.py Executable file
View file

@ -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()

View file

@ -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()

View file

@ -11,7 +11,7 @@ export MAX_LEN_6=64
mkdir -p generated mkdir -p generated
mkdir -p generated/dns mkdir -p generated/dns
scripts/dns-reverse-generator.py scripts/dns-generator.py
cp -R dns/* generated/dns cp -R dns/* generated/dns
scripts/roa.py -m "$MAX_LEN_4" -M "$MAX_LEN_6" -o generated/roa46_bird2.conf scripts/roa.py -m "$MAX_LEN_4" -M "$MAX_LEN_6" -o generated/roa46_bird2.conf