diff --git a/lib.py b/lib.py index d9c7616..ed75756 100644 --- a/lib.py +++ b/lib.py @@ -289,6 +289,25 @@ def aaaa_records_handler(re2o_zone, dns_zone): add_to_zone(dns_zone, key_name, AAAA_obj) +def cname_records_handler(re2o_zone, dns_zone): + """Handler fo CNAME records""" + + for record in re2o_zone["cname_records"]: + + logging.debug(f"CNAME = {record}") + + target = dns.name.from_text(record["alias"]) + name = dns.name.from_text(record["hostname"], origin=None) + + CNAME_obj = CNAME.CNAME( + dns.rdataclass.IN, + dns.rdatatype.CNAME, + target + ) + + add_to_zone(dns_zone, name, CNAME_obj) + + def pass_handler(zone, records): pass @@ -305,6 +324,6 @@ HANDLERS = { "a_records": a_records_handler, "aaaa_records": aaaa_records_handler, "name": pass_handler, - "cname_records": pass_handler, + "cname_records": cname_records_handler, "dname_records": pass_handler, }