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

add ds record, fix rfc2317 script

This commit is contained in:
JerryXiao 2021-04-14 20:15:56 +08:00
parent b2ed47f3ae
commit ed59726599
Signed by: Jerry
GPG key ID: 22618F758B5BE2E5
6 changed files with 26 additions and 11 deletions

View file

@ -58,6 +58,8 @@ $TTL 3600
9 IN NS ns1.jerry.neo. 9 IN NS ns1.jerry.neo.
9 IN NS ns2.jerry.neo. 9 IN NS ns2.jerry.neo.
9 IN NS ns3.jerry.neo.
9 IN DS 35017 13 2 31AA09841AF1F44753F0733ECD32A19E45368AAD4136B6AC75A3DCD257EFAA5C
10 IN NS ns-anycast.lantian.neo. 10 IN NS ns-anycast.lantian.neo.
10 IN NS ns1.lantian.neo. 10 IN NS ns1.lantian.neo.

View file

@ -20,6 +20,8 @@ $TTL 3600
; DELEGATED ZONES ; DELEGATED ZONES
3.5.0.0 IN NS ns1.jerry.neo. 3.5.0.0 IN NS ns1.jerry.neo.
3.5.0.0 IN NS ns2.jerry.neo. 3.5.0.0 IN NS ns2.jerry.neo.
3.5.0.0 IN NS ns3.jerry.neo.
3.5.0.0 IN DS 53626 13 2 F7F6AFCCA1CEC26E2A6EE9FAC9E11975260F00B8DC287D0B0FF428F775C62C5D
0.1.0.0 IN NS ns-anycast.lantian.neo. 0.1.0.0 IN NS ns-anycast.lantian.neo.
0.1.0.0 IN NS ns1.lantian.neo. 0.1.0.0 IN NS ns1.lantian.neo.

View file

@ -36,10 +36,13 @@ edwardp IN AAAA fd10:127:2f2f::
; DELEGATED ZONES ; DELEGATED ZONES
jerry IN NS ns1.jerry jerry IN NS ns1.jerry
jerry IN NS ns2.jerry jerry IN NS ns2.jerry
jerry IN DS 18792 13 2 2F335456EEE70FC4833886E5EEDC28E7195E90E2A337860B3E805D5EB9F3A804
ns1.jerry IN A 10.127.8.193 ns1.jerry IN A 10.127.8.193
ns1.jerry IN AAAA fd10:127:53::1 ns1.jerry IN AAAA fd10:127:53::1
ns2.jerry IN A 10.127.8.216 ns2.jerry IN A 10.127.8.216
ns2.jerry IN AAAA fd10:127:53:100::1 ns2.jerry IN AAAA fd10:127:53:100::1
ns3.jerry IN A 10.127.8.208
ns3.jerry IN AAAA fd10:127:53:200::1
kp IN NS ns1.kp kp IN NS ns1.kp
ns1.kp IN A 10.127.39.1 ns1.kp IN A 10.127.39.1

View file

@ -1,8 +1,11 @@
["10.127.8.64/26"] ["10.127.8.64/26"]
ns = ["ns1.jerry.neo.", "ns2.jerry.neo."] NS = ["ns1.jerry.neo.", "ns2.jerry.neo.", "ns3.jerry.neo."]
DS = ["24982 13 2 463EAE9D8248179806321A2ED3F05377234FD13DF0C2F20428C3B148F9C31B3D"]
TTL = -1
["10.127.8.192/26"] ["10.127.8.192/26"]
ns = ["ns1.jerry.neo.", "ns2.jerry.neo."] NS = ["ns1.jerry.neo.", "ns2.jerry.neo.", "ns3.jerry.neo."]
DS = ["12536 13 2 A2AEEFCDB5F0BB6C4AC075EF1034C5635AEFE5A2DA9E7FF7D8BBE53B5E61E8E3"]
["10.127.8.160/27"] ["10.127.8.160/27"]
ns = ["ns1.staph.neo."] NS = ["ns1.staph.neo."]

View file

@ -11,15 +11,17 @@ RFC2317_FILE = Path("dns", "rfc2317.toml")
def iter_rfc2317_entry(): def iter_rfc2317_entry():
entries = toml.loads(RFC2317_FILE.read_text()) entries = toml.loads(RFC2317_FILE.read_text())
for (route, attributes) in entries.items(): for (route, attributes) in entries.items():
ns = attributes.get('ns') ns = attributes.get('NS')
yield(route, ns) ds = attributes.get('DS', list())
ttl = attributes.get('TTL', -1)
yield(route, ns, ds, ttl)
def main(): def main():
orignal = RESOLVE_FILE.read_text() orignal = RESOLVE_FILE.read_text()
records = [orignal, "; AUTOGENERATED"] records = [orignal, "; AUTOGENERATED"]
records.extend(("", "; rfc2317")) records.extend(("", "; rfc2317"))
for route, ns in iter_rfc2317_entry(): for route, ns, ds, ttl in iter_rfc2317_entry():
records.extend(gen_reverse_pointers(route, ns)) records.extend(gen_reverse_pointers(route, ns, ds, ttl))
records.append("") records.append("")
RESOLVE_FILE.write_text("\n".join(records)) RESOLVE_FILE.write_text("\n".join(records))

View file

@ -8,19 +8,22 @@ def truncate(rev: str) -> str:
rev = rev[:-len(ZONE)] rev = rev[:-len(ZONE)]
return rev return rev
def gen_reverse_pointers(network: str, ns: list) -> list: def gen_reverse_pointers(network: str, ns: list, ds: list = [], ttl: int = -1) -> list:
ttl = f"{ttl} " if 900 <= ttl <= 86400 else ""
buf = list() buf = list()
net = ipaddress.IPv4Network(network, strict=True) net = ipaddress.IPv4Network(network, strict=True)
assert net.prefixlen > 24 assert net.prefixlen > 24
netrev = truncate(net.reverse_pointer) netrev = truncate(net.reverse_pointer)
for _ns in ns: for _ns in ns:
buf.append(f"{netrev:<10s} IN NS {_ns}") buf.append(f"{netrev} {ttl}IN NS {_ns}")
for _ds in ds:
buf.append(f"{netrev} {ttl}IN DS {_ds}")
for addr in net: for addr in net:
cnamefr = truncate(addr.reverse_pointer) cnamefr = truncate(addr.reverse_pointer)
cnameto = f"{int.from_bytes(addr.packed, byteorder='big', signed=False) & 0xff}.{netrev}" cnameto = f"{int.from_bytes(addr.packed, byteorder='big', signed=False) & 0xff}.{netrev}"
buf.append(f"{cnamefr:<10s} IN CNAME {cnameto}") buf.append(f"{cnamefr} {ttl}IN CNAME {cnameto}")
return buf return buf
if __name__ == "__main__": if __name__ == "__main__":
print("\n".join(gen_reverse_pointers('10.127.8.64/26', ['ns1.jerry.neo.']))) print("\n".join(gen_reverse_pointers('10.127.8.64/26', ['ns1.jerry.neo.'], ['18792 13 2 2F335456EEE70FC4833886E5EEDC28E7195E90E2A337860B3E805D5EB9F3A804'], ttl=1500)))