mirror of
https://github.com/NeoCloud/NeoNetwork
synced 2024-11-22 12:40:40 +08:00
format dns and change ttl
This commit is contained in:
parent
492138d848
commit
749b5cf78c
5 changed files with 206 additions and 151 deletions
|
@ -1,15 +1,15 @@
|
|||
; NeoNetwork DNS Record
|
||||
$TTL 604800
|
||||
@ IN SOA NeoPDP-11.neo. root.neo. (
|
||||
$TTL 3600
|
||||
@ IN SOA root-dns.neo. root.neo. (
|
||||
4096 ; Serial
|
||||
604800 ; Refresh
|
||||
86400 ; Retry
|
||||
2419200 ; Expire
|
||||
604800 ) ; Negative Cache TTL
|
||||
900 ; Refresh
|
||||
900 ; Retry
|
||||
86400 ; Expire
|
||||
900 ) ; Negative Cache TTL
|
||||
;
|
||||
@ IN NS NeoPDP-11.neo.
|
||||
|
||||
;
|
||||
|
||||
1.1 IN PTR NeoPDP-11.neo.
|
||||
40.1 IN PTR cklvax.neo.
|
||||
63.1 IN PTR NNPCC.neo.
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
; NeoNetwork DNS Record
|
||||
$TTL 604800
|
||||
@ IN SOA NeoPDP-11.neo. root.neo. (
|
||||
$TTL 3600
|
||||
@ IN SOA root-dns.neo. root.neo. (
|
||||
4096 ; Serial
|
||||
604800 ; Refresh
|
||||
86400 ; Retry
|
||||
2419200 ; Expire
|
||||
604800 ) ; Negative Cache TTL
|
||||
900 ; Refresh
|
||||
900 ; Retry
|
||||
86400 ; Expire
|
||||
900 ) ; Negative Cache TTL
|
||||
;
|
||||
@ IN NS NeoPDP-11.neo.
|
||||
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
; NeoNetwork DNS Record
|
||||
|
||||
$TTL 604800
|
||||
@ IN SOA NeoPDP-11.neo. root.neo. (
|
||||
$TTL 3600
|
||||
@ IN SOA root-dns.neo. root.neo. (
|
||||
4096 ; Serial
|
||||
604800 ; Refresh
|
||||
86400 ; Retry
|
||||
2419200 ; Expire
|
||||
604800 ) ; Negative Cache TTL
|
||||
900 ; Refresh
|
||||
900 ; Retry
|
||||
86400 ; Expire
|
||||
900 ) ; Negative Cache TTL
|
||||
;
|
||||
|
||||
; NeoNetwork Original
|
||||
|
|
|
@ -13,7 +13,7 @@ install() {
|
|||
install || { sudo apt update -qq; install; }
|
||||
|
||||
check() {
|
||||
PATH=/sbin:/usr/sbin:$PATH named-checkzone -i local $@
|
||||
PATH=/sbin:/usr/sbin:$PATH named-checkzone -i local -l 86400 $@
|
||||
}
|
||||
|
||||
pushd dns
|
||||
|
|
56
scripts/named-formatzone.py
Normal file
56
scripts/named-formatzone.py
Normal 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))
|
Loading…
Reference in a new issue