mirror of
https://github.com/NeoCloud/NeoNetwork
synced 2024-12-25 13:09:23 +08:00
add ds record, fix rfc2317 script
This commit is contained in:
parent
b2ed47f3ae
commit
ed59726599
6 changed files with 26 additions and 11 deletions
|
@ -58,6 +58,8 @@ $TTL 3600
|
|||
|
||||
9 IN NS ns1.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 ns1.lantian.neo.
|
||||
|
|
|
@ -20,6 +20,8 @@ $TTL 3600
|
|||
; DELEGATED ZONES
|
||||
3.5.0.0 IN NS ns1.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 ns1.lantian.neo.
|
||||
|
|
|
@ -36,10 +36,13 @@ edwardp IN AAAA fd10:127:2f2f::
|
|||
; DELEGATED ZONES
|
||||
jerry IN NS ns1.jerry
|
||||
jerry IN NS ns2.jerry
|
||||
jerry IN DS 18792 13 2 2F335456EEE70FC4833886E5EEDC28E7195E90E2A337860B3E805D5EB9F3A804
|
||||
ns1.jerry IN A 10.127.8.193
|
||||
ns1.jerry IN AAAA fd10:127:53::1
|
||||
ns2.jerry IN A 10.127.8.216
|
||||
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
|
||||
ns1.kp IN A 10.127.39.1
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
["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"]
|
||||
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"]
|
||||
ns = ["ns1.staph.neo."]
|
||||
NS = ["ns1.staph.neo."]
|
||||
|
|
|
@ -11,15 +11,17 @@ 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)
|
||||
ns = attributes.get('NS')
|
||||
ds = attributes.get('DS', list())
|
||||
ttl = attributes.get('TTL', -1)
|
||||
yield(route, ns, ds, ttl)
|
||||
|
||||
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))
|
||||
for route, ns, ds, ttl in iter_rfc2317_entry():
|
||||
records.extend(gen_reverse_pointers(route, ns, ds, ttl))
|
||||
records.append("")
|
||||
|
||||
RESOLVE_FILE.write_text("\n".join(records))
|
||||
|
|
|
@ -8,19 +8,22 @@ def truncate(rev: str) -> str:
|
|||
rev = rev[:-len(ZONE)]
|
||||
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()
|
||||
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}")
|
||||
buf.append(f"{netrev} {ttl}IN NS {_ns}")
|
||||
for _ds in ds:
|
||||
buf.append(f"{netrev} {ttl}IN DS {_ds}")
|
||||
|
||||
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}")
|
||||
buf.append(f"{cnamefr} {ttl}IN CNAME {cnameto}")
|
||||
return buf
|
||||
|
||||
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)))
|
||||
|
|
Loading…
Reference in a new issue