From 2fa0aece480dc90dfb53e5da7979dededb75e867 Mon Sep 17 00:00:00 2001 From: Otthorn Date: Fri, 9 Apr 2021 06:23:14 +0200 Subject: [PATCH] :sparkles: Add CNAME handler --- lib.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) 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, }