From 8447fa0db941b6d582ca40f2e8dd3081887ba1cb Mon Sep 17 00:00:00 2001 From: Otthorn Date: Wed, 14 Apr 2021 19:16:06 +0200 Subject: [PATCH] Update serial number correctly --- lib.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib.py b/lib.py index 7f6f5af..a2ed53e 100644 --- a/lib.py +++ b/lib.py @@ -82,6 +82,17 @@ def get_serial(dns_zone): return serial +def update_serial(serial, serial_bits=32): + """Update serial number + + According to RFC 1982 and Knot implementation. + SERIAL_BITS = 32 by default. + """ + + serial = serial + 1 % 2**32 + + return serial + def soa_handler(re2o_zone, dns_zone): """Handler for SOA record""" @@ -93,6 +104,7 @@ def soa_handler(re2o_zone, dns_zone): origin = dns_zone.origin serial = get_serial(origin) + serial = update_serial(serial) logging.debug(f"[SOA] zone_origin={origin} serial={serial}") soa_obj = SOA.SOA(