mirror of
https://github.com/NeoCloud/NeoNetwork
synced 2024-12-25 13:49:23 +08:00
add update-zone-serial tool
This commit is contained in:
parent
869e88373e
commit
d43f56225b
5 changed files with 58 additions and 15 deletions
|
@ -1,11 +1,11 @@
|
||||||
; NeoNetwork DNS Record
|
; NeoNetwork DNS Record
|
||||||
$TTL 3600
|
$TTL 3600
|
||||||
@ IN SOA root-dns.neo. root.neo. (
|
@ IN SOA root-dns.neo. root.neo. (
|
||||||
4096 ; Serial
|
4096 ; Serial
|
||||||
900 ; Refresh
|
900 ; Refresh
|
||||||
900 ; Retry
|
900 ; Retry
|
||||||
86400 ; Expire
|
86400 ; Expire
|
||||||
900 ) ; Negative Cache TTL
|
900 ) ; Negative Cache TTL
|
||||||
;
|
;
|
||||||
@ IN NS NeoPDP-11.neo.
|
@ IN NS NeoPDP-11.neo.
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
; NeoNetwork DNS Record
|
; NeoNetwork DNS Record
|
||||||
$TTL 3600
|
$TTL 3600
|
||||||
@ IN SOA root-dns.neo. root.neo. (
|
@ IN SOA root-dns.neo. root.neo. (
|
||||||
4096 ; Serial
|
4096 ; Serial
|
||||||
900 ; Refresh
|
900 ; Refresh
|
||||||
900 ; Retry
|
900 ; Retry
|
||||||
86400 ; Expire
|
86400 ; Expire
|
||||||
900 ) ; Negative Cache TTL
|
900 ) ; Negative Cache TTL
|
||||||
;
|
;
|
||||||
@ IN NS NeoPDP-11.neo.
|
@ IN NS NeoPDP-11.neo.
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
; NeoNetwork DNS Record
|
; NeoNetwork DNS Record
|
||||||
$TTL 3600
|
$TTL 3600
|
||||||
@ IN SOA root-dns.neo. root.neo. (
|
@ IN SOA root-dns.neo. root.neo. (
|
||||||
4096 ; Serial
|
4096 ; Serial
|
||||||
900 ; Refresh
|
900 ; Refresh
|
||||||
900 ; Retry
|
900 ; Retry
|
||||||
86400 ; Expire
|
86400 ; Expire
|
||||||
900 ) ; Negative Cache TTL
|
900 ) ; Negative Cache TTL
|
||||||
;
|
;
|
||||||
|
|
||||||
; NeoNetwork Original
|
; NeoNetwork Original
|
||||||
|
|
|
@ -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 -m "$MAX_LEN_4" -M "$MAX_LEN_6" -r -o generated/rfc8416.json
|
||||||
scripts/roa.py --summary --output generated/README.md
|
scripts/roa.py --summary --output generated/README.md
|
||||||
|
|
||||||
|
scripts/update-zone-serial.py
|
||||||
|
|
||||||
scripts/check-named-zones.sh
|
scripts/check-named-zones.sh
|
||||||
|
|
41
scripts/update-zone-serial.py
Executable file
41
scripts/update-zone-serial.py
Executable 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))
|
Loading…
Reference in a new issue