Update serial number correctly

This commit is contained in:
otthorn 2021-04-14 19:16:06 +02:00
parent 663133f9cb
commit 8447fa0db9

12
lib.py
View file

@ -82,6 +82,17 @@ def get_serial(dns_zone):
return serial 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): def soa_handler(re2o_zone, dns_zone):
"""Handler for SOA record""" """Handler for SOA record"""
@ -93,6 +104,7 @@ def soa_handler(re2o_zone, dns_zone):
origin = dns_zone.origin origin = dns_zone.origin
serial = get_serial(origin) serial = get_serial(origin)
serial = update_serial(serial)
logging.debug(f"[SOA] zone_origin={origin} serial={serial}") logging.debug(f"[SOA] zone_origin={origin} serial={serial}")
soa_obj = SOA.SOA( soa_obj = SOA.SOA(