1
0
Fork 0
mirror of https://github.com/NeoCloud/NeoNetwork synced 2024-11-22 06:10:42 +08:00

rfc2317 script

This commit is contained in:
JerryXiao 2020-09-23 14:41:36 +08:00
parent 61224360eb
commit 47cfb85f58
Signed by: Jerry
GPG key ID: 9D9CE43650FF2BAA
4 changed files with 226 additions and 102 deletions

View file

@ -36,71 +36,6 @@ $TTL 604800
2.8 IN PTR blog.librehs.neo.
; DELEGATED ZONES
192/26.8 IN NS ns1.jerry.neo.
192.8 IN CNAME 192.192/26.8
193.8 IN CNAME 193.192/26.8
194.8 IN CNAME 194.192/26.8
195.8 IN CNAME 195.192/26.8
196.8 IN CNAME 196.192/26.8
197.8 IN CNAME 197.192/26.8
198.8 IN CNAME 198.192/26.8
199.8 IN CNAME 199.192/26.8
200.8 IN CNAME 200.192/26.8
201.8 IN CNAME 201.192/26.8
202.8 IN CNAME 202.192/26.8
203.8 IN CNAME 203.192/26.8
204.8 IN CNAME 204.192/26.8
205.8 IN CNAME 205.192/26.8
206.8 IN CNAME 206.192/26.8
207.8 IN CNAME 207.192/26.8
208.8 IN CNAME 208.192/26.8
209.8 IN CNAME 209.192/26.8
210.8 IN CNAME 210.192/26.8
211.8 IN CNAME 211.192/26.8
212.8 IN CNAME 212.192/26.8
213.8 IN CNAME 213.192/26.8
214.8 IN CNAME 214.192/26.8
215.8 IN CNAME 215.192/26.8
216.8 IN CNAME 216.192/26.8
217.8 IN CNAME 217.192/26.8
218.8 IN CNAME 218.192/26.8
219.8 IN CNAME 219.192/26.8
220.8 IN CNAME 220.192/26.8
221.8 IN CNAME 221.192/26.8
222.8 IN CNAME 222.192/26.8
223.8 IN CNAME 223.192/26.8
224.8 IN CNAME 224.192/26.8
225.8 IN CNAME 225.192/26.8
226.8 IN CNAME 226.192/26.8
227.8 IN CNAME 227.192/26.8
228.8 IN CNAME 228.192/26.8
229.8 IN CNAME 229.192/26.8
230.8 IN CNAME 230.192/26.8
231.8 IN CNAME 231.192/26.8
232.8 IN CNAME 232.192/26.8
233.8 IN CNAME 233.192/26.8
234.8 IN CNAME 234.192/26.8
235.8 IN CNAME 235.192/26.8
236.8 IN CNAME 236.192/26.8
237.8 IN CNAME 237.192/26.8
238.8 IN CNAME 238.192/26.8
239.8 IN CNAME 239.192/26.8
240.8 IN CNAME 240.192/26.8
241.8 IN CNAME 241.192/26.8
242.8 IN CNAME 242.192/26.8
243.8 IN CNAME 243.192/26.8
244.8 IN CNAME 244.192/26.8
245.8 IN CNAME 245.192/26.8
246.8 IN CNAME 246.192/26.8
247.8 IN CNAME 247.192/26.8
248.8 IN CNAME 248.192/26.8
249.8 IN CNAME 249.192/26.8
250.8 IN CNAME 250.192/26.8
251.8 IN CNAME 251.192/26.8
252.8 IN CNAME 252.192/26.8
253.8 IN CNAME 253.192/26.8
254.8 IN CNAME 254.192/26.8
255.8 IN CNAME 255.192/26.8
9 IN NS ns1.jerry.neo.
12 IN NS ns1.yangfl.dn42.
@ -113,49 +48,183 @@ $TTL 604800
10 IN NS ns5.lantian.neo.
7 IN NS ns1.staph.neo.
160/27.8 IN NS ns1.staph.neo.
160.8 IN CNAME 160.160/27.8
161.8 IN CNAME 161.160/27.8
162.8 IN CNAME 162.160/27.8
163.8 IN CNAME 163.160/27.8
164.8 IN CNAME 164.160/27.8
165.8 IN CNAME 165.160/27.8
166.8 IN CNAME 166.160/27.8
167.8 IN CNAME 167.160/27.8
168.8 IN CNAME 168.160/27.8
169.8 IN CNAME 169.160/27.8
170.8 IN CNAME 170.160/27.8
171.8 IN CNAME 171.160/27.8
172.8 IN CNAME 172.160/27.8
173.8 IN CNAME 173.160/27.8
174.8 IN CNAME 174.160/27.8
175.8 IN CNAME 175.160/27.8
176.8 IN CNAME 176.160/27.8
177.8 IN CNAME 177.160/27.8
178.8 IN CNAME 178.160/27.8
179.8 IN CNAME 179.160/27.8
180.8 IN CNAME 180.160/27.8
181.8 IN CNAME 181.160/27.8
182.8 IN CNAME 182.160/27.8
183.8 IN CNAME 183.160/27.8
184.8 IN CNAME 184.160/27.8
185.8 IN CNAME 185.160/27.8
186.8 IN CNAME 186.160/27.8
187.8 IN CNAME 187.160/27.8
188.8 IN CNAME 188.160/27.8
189.8 IN CNAME 189.160/27.8
190.8 IN CNAME 190.160/27.8
191.8 IN CNAME 191.160/27.8
; DO NOT MANUALLY EDIT THE FOLLOWING LINES
; AUTOGENERATED
; Loopback Addresses
3.89 IN PTR chenx97-conoha.neo.
1.255 IN PTR NeoPDP-11.neo.
2.255 IN PTR ucbvax.neo.
4.255 IN PTR pan.neo.
53.255 IN PTR JerryXiao-Anycast.neo.
53.255 IN PTR JerryXiao-Anycast4.neo.
56.255 IN PTR frank-hsinchu-1.neo.
80.255 IN PTR NeoSystem.neo.
117.255 IN PTR magicneko-tw.neo.
; rfc2317
64/26.8 IN NS ns1.jerry.neo.
64.8 IN CNAME 64.64/26.8
65.8 IN CNAME 65.64/26.8
66.8 IN CNAME 66.64/26.8
67.8 IN CNAME 67.64/26.8
68.8 IN CNAME 68.64/26.8
69.8 IN CNAME 69.64/26.8
70.8 IN CNAME 70.64/26.8
71.8 IN CNAME 71.64/26.8
72.8 IN CNAME 72.64/26.8
73.8 IN CNAME 73.64/26.8
74.8 IN CNAME 74.64/26.8
75.8 IN CNAME 75.64/26.8
76.8 IN CNAME 76.64/26.8
77.8 IN CNAME 77.64/26.8
78.8 IN CNAME 78.64/26.8
79.8 IN CNAME 79.64/26.8
80.8 IN CNAME 80.64/26.8
81.8 IN CNAME 81.64/26.8
82.8 IN CNAME 82.64/26.8
83.8 IN CNAME 83.64/26.8
84.8 IN CNAME 84.64/26.8
85.8 IN CNAME 85.64/26.8
86.8 IN CNAME 86.64/26.8
87.8 IN CNAME 87.64/26.8
88.8 IN CNAME 88.64/26.8
89.8 IN CNAME 89.64/26.8
90.8 IN CNAME 90.64/26.8
91.8 IN CNAME 91.64/26.8
92.8 IN CNAME 92.64/26.8
93.8 IN CNAME 93.64/26.8
94.8 IN CNAME 94.64/26.8
95.8 IN CNAME 95.64/26.8
96.8 IN CNAME 96.64/26.8
97.8 IN CNAME 97.64/26.8
98.8 IN CNAME 98.64/26.8
99.8 IN CNAME 99.64/26.8
100.8 IN CNAME 100.64/26.8
101.8 IN CNAME 101.64/26.8
102.8 IN CNAME 102.64/26.8
103.8 IN CNAME 103.64/26.8
104.8 IN CNAME 104.64/26.8
105.8 IN CNAME 105.64/26.8
106.8 IN CNAME 106.64/26.8
107.8 IN CNAME 107.64/26.8
108.8 IN CNAME 108.64/26.8
109.8 IN CNAME 109.64/26.8
110.8 IN CNAME 110.64/26.8
111.8 IN CNAME 111.64/26.8
112.8 IN CNAME 112.64/26.8
113.8 IN CNAME 113.64/26.8
114.8 IN CNAME 114.64/26.8
115.8 IN CNAME 115.64/26.8
116.8 IN CNAME 116.64/26.8
117.8 IN CNAME 117.64/26.8
118.8 IN CNAME 118.64/26.8
119.8 IN CNAME 119.64/26.8
120.8 IN CNAME 120.64/26.8
121.8 IN CNAME 121.64/26.8
122.8 IN CNAME 122.64/26.8
123.8 IN CNAME 123.64/26.8
124.8 IN CNAME 124.64/26.8
125.8 IN CNAME 125.64/26.8
126.8 IN CNAME 126.64/26.8
127.8 IN CNAME 127.64/26.8
192/26.8 IN NS ns1.jerry.neo.
192.8 IN CNAME 192.192/26.8
193.8 IN CNAME 193.192/26.8
194.8 IN CNAME 194.192/26.8
195.8 IN CNAME 195.192/26.8
196.8 IN CNAME 196.192/26.8
197.8 IN CNAME 197.192/26.8
198.8 IN CNAME 198.192/26.8
199.8 IN CNAME 199.192/26.8
200.8 IN CNAME 200.192/26.8
201.8 IN CNAME 201.192/26.8
202.8 IN CNAME 202.192/26.8
203.8 IN CNAME 203.192/26.8
204.8 IN CNAME 204.192/26.8
205.8 IN CNAME 205.192/26.8
206.8 IN CNAME 206.192/26.8
207.8 IN CNAME 207.192/26.8
208.8 IN CNAME 208.192/26.8
209.8 IN CNAME 209.192/26.8
210.8 IN CNAME 210.192/26.8
211.8 IN CNAME 211.192/26.8
212.8 IN CNAME 212.192/26.8
213.8 IN CNAME 213.192/26.8
214.8 IN CNAME 214.192/26.8
215.8 IN CNAME 215.192/26.8
216.8 IN CNAME 216.192/26.8
217.8 IN CNAME 217.192/26.8
218.8 IN CNAME 218.192/26.8
219.8 IN CNAME 219.192/26.8
220.8 IN CNAME 220.192/26.8
221.8 IN CNAME 221.192/26.8
222.8 IN CNAME 222.192/26.8
223.8 IN CNAME 223.192/26.8
224.8 IN CNAME 224.192/26.8
225.8 IN CNAME 225.192/26.8
226.8 IN CNAME 226.192/26.8
227.8 IN CNAME 227.192/26.8
228.8 IN CNAME 228.192/26.8
229.8 IN CNAME 229.192/26.8
230.8 IN CNAME 230.192/26.8
231.8 IN CNAME 231.192/26.8
232.8 IN CNAME 232.192/26.8
233.8 IN CNAME 233.192/26.8
234.8 IN CNAME 234.192/26.8
235.8 IN CNAME 235.192/26.8
236.8 IN CNAME 236.192/26.8
237.8 IN CNAME 237.192/26.8
238.8 IN CNAME 238.192/26.8
239.8 IN CNAME 239.192/26.8
240.8 IN CNAME 240.192/26.8
241.8 IN CNAME 241.192/26.8
242.8 IN CNAME 242.192/26.8
243.8 IN CNAME 243.192/26.8
244.8 IN CNAME 244.192/26.8
245.8 IN CNAME 245.192/26.8
246.8 IN CNAME 246.192/26.8
247.8 IN CNAME 247.192/26.8
248.8 IN CNAME 248.192/26.8
249.8 IN CNAME 249.192/26.8
250.8 IN CNAME 250.192/26.8
251.8 IN CNAME 251.192/26.8
252.8 IN CNAME 252.192/26.8
253.8 IN CNAME 253.192/26.8
254.8 IN CNAME 254.192/26.8
255.8 IN CNAME 255.192/26.8
160/27.8 IN NS ns1.staph.neo.
160.8 IN CNAME 160.160/27.8
161.8 IN CNAME 161.160/27.8
162.8 IN CNAME 162.160/27.8
163.8 IN CNAME 163.160/27.8
164.8 IN CNAME 164.160/27.8
165.8 IN CNAME 165.160/27.8
166.8 IN CNAME 166.160/27.8
167.8 IN CNAME 167.160/27.8
168.8 IN CNAME 168.160/27.8
169.8 IN CNAME 169.160/27.8
170.8 IN CNAME 170.160/27.8
171.8 IN CNAME 171.160/27.8
172.8 IN CNAME 172.160/27.8
173.8 IN CNAME 173.160/27.8
174.8 IN CNAME 174.160/27.8
175.8 IN CNAME 175.160/27.8
176.8 IN CNAME 176.160/27.8
177.8 IN CNAME 177.160/27.8
178.8 IN CNAME 178.160/27.8
179.8 IN CNAME 179.160/27.8
180.8 IN CNAME 180.160/27.8
181.8 IN CNAME 181.160/27.8
182.8 IN CNAME 182.160/27.8
183.8 IN CNAME 183.160/27.8
184.8 IN CNAME 184.160/27.8
185.8 IN CNAME 185.160/27.8
186.8 IN CNAME 186.160/27.8
187.8 IN CNAME 187.160/27.8
188.8 IN CNAME 188.160/27.8
189.8 IN CNAME 189.160/27.8
190.8 IN CNAME 190.160/27.8
191.8 IN CNAME 191.160/27.8

8
dns/rfc2317.toml Normal file
View file

@ -0,0 +1,8 @@
["10.127.8.64/26"]
ns = ["ns1.jerry.neo."]
["10.127.8.192/26"]
ns = ["ns1.jerry.neo."]
["10.127.8.160/27"]
ns = ["ns1.staph.neo."]

View file

@ -4,10 +4,11 @@ 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 = []
@ -18,8 +19,22 @@ def iter_route(route_type: str):
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()
@ -29,7 +44,13 @@ def main():
if isinstance(address, IPv4Address):
pointer = address.reverse_pointer.replace(".127.10.in-addr.arpa", "")
records.append("%s\tIN\tPTR\t%s.neo." % (pointer, name))
RESOLVE_FILE.write_text("\n".join(records)+"\n")
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__":

26
scripts/rfc2317.py Executable file
View file

@ -0,0 +1,26 @@
#!/usr/bin/env python3
import ipaddress
ZONE = '.127.10.in-addr.arpa'
def truncate(rev: str) -> str:
assert rev.endswith(ZONE)
rev = rev[:-len(ZONE)]
return rev
def gen_reverse_pointers(network: str, ns: list) -> list:
buf = list()
net = ipaddress.IPv4Network(network, strict=True)
assert net.prefixlen > 24
netrev = truncate(net.reverse_pointer)
for _ns in ns:
buf.append(f"{netrev:<10s} IN NS {_ns}")
for addr in net:
cnamefr = truncate(addr.reverse_pointer)
cnameto = f"{int.from_bytes(addr.packed, byteorder='big', signed=False) & 0xff}.{netrev}"
buf.append(f"{cnamefr:<10s} IN CNAME {cnameto}")
return buf
if __name__ == "__main__":
print("\n".join(gen_reverse_pointers('10.127.8.64/26', ['ns1.jerry.neo.'])))