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

format dns and change ttl

This commit is contained in:
JerryXiao 2021-04-14 14:30:56 +08:00
parent 492138d848
commit 749b5cf78c
Signed by: Jerry
GPG key ID: 22618F758B5BE2E5
5 changed files with 206 additions and 151 deletions

View file

@ -1,15 +1,15 @@
; NeoNetwork DNS Record ; NeoNetwork DNS Record
$TTL 604800 $TTL 3600
@ IN SOA NeoPDP-11.neo. root.neo. ( @ IN SOA root-dns.neo. root.neo. (
4096 ; Serial 4096 ; Serial
604800 ; Refresh 900 ; Refresh
86400 ; Retry 900 ; Retry
2419200 ; Expire 86400 ; Expire
604800 ) ; Negative Cache TTL 900 ) ; Negative Cache TTL
; ;
@ IN NS NeoPDP-11.neo. @ IN NS NeoPDP-11.neo.
;
1.1 IN PTR NeoPDP-11.neo. 1.1 IN PTR NeoPDP-11.neo.
40.1 IN PTR cklvax.neo. 40.1 IN PTR cklvax.neo.
63.1 IN PTR NNPCC.neo. 63.1 IN PTR NNPCC.neo.

View file

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

View file

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

View file

@ -13,7 +13,7 @@ install() {
install || { sudo apt update -qq; install; } install || { sudo apt update -qq; install; }
check() { check() {
PATH=/sbin:/usr/sbin:$PATH named-checkzone -i local $@ PATH=/sbin:/usr/sbin:$PATH named-checkzone -i local -l 86400 $@
} }
pushd dns pushd dns

View file

@ -0,0 +1,56 @@
#!/usr/bin/env python3
# highly explosive
import argparse
from pathlib import Path
if __name__ == "__main__":
parser = argparse.ArgumentParser('named-formatzone')
parser.add_argument("file")
args = parser.parse_args()
zonefile = Path(args.file)
zonelines = zonefile.read_text().split('\n')
formatted = list()
max_length = [0, 0, 0, 0, 0]
in_soa = False
def iter_lines(scan_only=True):
soafound = None
for rline in zonelines:
line, *comments = rline.split(';')
comments = ";".join(comments)
line = line.strip()
if "SOA" in line and soafound is None:
soafound = True
else:
if "IN" in line and soafound is True:
soafound = False
if soafound is False and line:
cols = line.split()
if len(cols) != 5:
cols.insert(1, "")
print(cols)
name, ttl, _in, rrtype, *record = cols
record = " ".join(record)
cols = (name, ttl, _in, rrtype, record)
assert _in == "IN"
if scan_only:
for i, entry in enumerate(cols):
max_length[i] = max(max_length[i], len(entry))
else:
fmtlline = list()
for i, entry in enumerate(cols):
entry += " "*(max_length[i]-len(entry)+3)
if entry:
fmtlline.append(entry)
fmtline = " ".join(fmtlline)
formatted.append(f"{fmtline} ;{comments}" if comments else fmtline)
formatted[-1] = formatted[-1].strip()
else:
if not scan_only:
formatted.append(rline)
iter_lines()
iter_lines(False)
zonefile.write_text("\n".join(formatted))