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

add update-zone-serial tool

This commit is contained in:
JerryXiao 2021-04-14 23:11:55 +08:00
parent 869e88373e
commit d43f56225b
Signed by: Jerry
GPG key ID: 22618F758B5BE2E5
5 changed files with 58 additions and 15 deletions

View file

@ -1,11 +1,11 @@
; NeoNetwork DNS Record
$TTL 3600
@ IN SOA root-dns.neo. root.neo. (
4096 ; Serial
900 ; Refresh
900 ; Retry
86400 ; Expire
900 ) ; Negative Cache TTL
4096 ; Serial
900 ; Refresh
900 ; Retry
86400 ; Expire
900 ) ; Negative Cache TTL
;
@ IN NS NeoPDP-11.neo.

View file

@ -1,11 +1,11 @@
; NeoNetwork DNS Record
$TTL 3600
@ IN SOA root-dns.neo. root.neo. (
4096 ; Serial
900 ; Refresh
900 ; Retry
86400 ; Expire
900 ) ; Negative Cache TTL
4096 ; Serial
900 ; Refresh
900 ; Retry
86400 ; Expire
900 ) ; Negative Cache TTL
;
@ IN NS NeoPDP-11.neo.

View file

@ -1,11 +1,11 @@
; NeoNetwork DNS Record
$TTL 3600
@ IN SOA root-dns.neo. root.neo. (
4096 ; Serial
900 ; Refresh
900 ; Retry
86400 ; Expire
900 ) ; Negative Cache TTL
4096 ; Serial
900 ; Refresh
900 ; Retry
86400 ; Expire
900 ) ; Negative Cache TTL
;
; NeoNetwork Original

View file

@ -22,4 +22,6 @@ scripts/roa.py -m "$MAX_LEN_4" -M "$MAX_LEN_6" -e -o generated/neonetwork.json
scripts/roa.py -m "$MAX_LEN_4" -M "$MAX_LEN_6" -r -o generated/rfc8416.json
scripts/roa.py --summary --output generated/README.md
scripts/update-zone-serial.py
scripts/check-named-zones.sh

41
scripts/update-zone-serial.py Executable file
View file

@ -0,0 +1,41 @@
#!/usr/bin/env python3
from pathlib import Path
import subprocess
from time import time
from re import match
from os import chdir
chdir("generated")
zone_files = [
'neonetwork',
'db.10.127',
'db.fd10.127',
]
serial_base = 1586876035
for zone in zone_files:
zone = Path("dns") / zone
assert zone.exists()
p = subprocess.run(['git', 'diff', '--exit-code', str(zone)])
if p.returncode == 0:
print(f"skip {zone.name}")
else:
print(f"update serial {zone.name}")
lines = zone.read_text().split("\n")
processed = list()
serial = int(time()) - serial_base
assert 0 < serial <= 2**32
serial = str(serial)
found = False
for line in lines:
if not found and (m := match(r"^(\s+)([0-9]+)(\s*;\s*Serial\s*)$", line)):
prefix, _serial, suffix = m.groups()
print(f"{_serial=} {serial=}")
plen = max(len(prefix) - len(serial) + len(_serial), 0)
processed.append(f"{' '*plen}{serial}{suffix}")
found = True
else:
processed.append(line)
zone.write_text("\n".join(processed))