From b7a11b42a3060c13c010a9c0225c74b3edbb6ab1 Mon Sep 17 00:00:00 2001 From: Rottler Tamas Date: Thu, 29 May 2025 15:04:28 +0200 Subject: [PATCH] omit IN class in zone files --- autorev2 | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/autorev2 b/autorev2 index 191d259..e60215c 100755 --- a/autorev2 +++ b/autorev2 @@ -82,7 +82,7 @@ class Rev: rec = self.revzones[zone]['ptr'][ip] if rec['noauto'] or rec['wikionly']: continue; - ptr.append(f"{rec['ptr']}\t\tIN PTR\t{rec['name']}") + ptr.append(f"{rec['ptr']}\t\tPTR\t{rec['name']}") return other + ptr def zone_wiki(self, zone): @@ -153,8 +153,8 @@ def read_zone(zonefile, rev): print(f"warning: legacy [vlan] in zone file {zonefile}") if not revzone or not origin: continue - if r := re.match(r"\s*([a-z0-9.-]+)\s+IN\s+A\s+([0-9.]+)(.*)", line, flags=re.I): - name, addr, extra = r[1], r[2], r[3] + if r := re.match(r"([a-z0-9.-]+)\s+(IN\s+)?A\s+([0-9.]+)(.*)", line, flags=re.I): + name, addr, extra = r[1], r[3], r[4] if re.search(r"\[no_autorev\]", extra): continue try: @@ -197,14 +197,14 @@ def process_oldrev(oldrev, revfile, rev): #print(f"revzone: {revzone}") elif r := re.match(r"\s*;\s*\[info\]\s*(.*)", line): rev.add_zone_info(revzone, r[1]) - elif r := re.match(r"\s*([0-9.]+)\s+IN\s+PTR\s+(\S+)", line, flags=re.I): + elif r := re.match(r"([0-9.]+)\s+(IN\s+)?PTR\s+(\S+)", line, flags=re.I): if not revzone: print(f"PTR record before $ORIGIN in: {revfile}") exit(1) ip = revzone +"."+ ".".join(reversed(re.split(r"\.", r[1]))) - #print(f"ptr: {ip} {r[2]}") + #print(f"ptr: {ip} {r[3]}") try: - rev.ptr(revzone, ip, r[2], noauto=True) + rev.ptr(revzone, ip, r[3], noauto=True) except (RevDuplicateAddress, RevInvalidAddress) as e: print(e, file=sys.stderr) exit(1) @@ -215,9 +215,9 @@ def process_oldrev(oldrev, revfile, rev): def serial_incr(zone, zonefile): - if not (r := re.search(r"IN\s+SOA.*?\s+(\d{1,10})\s", zone)): + if not (r := re.search(r"(IN\s+)?SOA.*?\s+(\d{1,10})\s", zone)): print(f"no SOA record found in {zonefile}", file=sys.stderr) - oldserial = r[1] + oldserial = r[2] if len(oldserial) == 9: revdigits = 1 revbase = 10 @@ -250,7 +250,7 @@ def serial_incr(zone, zonefile): newserial = f"{newdate}{newrev:02}" #print(f"serial {oldserial} -> {newserial}") - return re.sub(r"(IN\s+SOA.*?\s+)"+ oldserial, f"\\g<1>{newserial}", zone) + return re.sub(r"((IN\s+)?SOA.*?\s+)"+ oldserial, f"\\g<1>{newserial}", zone) def dokuwiki_update(text):