Add support for record-level TTL

This commit is contained in:
jeltz 2021-04-17 20:39:38 +02:00
parent 80ae6c7760
commit fe4307f402

24
lib.py
View file

@ -52,7 +52,7 @@ def format_re2o_domain(name: str):
return name_obj
def add_to_zone(zone, name, rdata):
def add_to_zone(zone, name, rdata, ttl=None):
"""Add a rdata object to a zone object."""
node = zone.find_node(name, create=True)
@ -61,7 +61,7 @@ def add_to_zone(zone, name, rdata):
rdata.rdtype,
create=True
)
rdataset.add(rdata)
rdataset.add(rdata, ttl=ttl)
def get_serial(dns_zone):
@ -170,7 +170,7 @@ def ns_records_handler(re2o_zone, dns_zone):
target_obj
)
add_to_zone(dns_zone, AT, NS_obj)
add_to_zone(dns_zone, AT, NS_obj, record["ttl"])
def sshfp_record_handler(re2o_zone, dns_zone):
@ -199,7 +199,7 @@ def sshfp_record_handler(re2o_zone, dns_zone):
fingerprint,
)
add_to_zone(dns_zone, name_obj, SSHFP_obj)
add_to_zone(dns_zone, name_obj, SSHFP_obj, record["ttl"])
def mx_records_handler(re2o_zone, dns_zone):
@ -221,7 +221,7 @@ def mx_records_handler(re2o_zone, dns_zone):
exchange_obj
)
add_to_zone(dns_zone, AT, MX_obj)
add_to_zone(dns_zone, AT, MX_obj, record["ttl"])
def txt_records_handler(re2o_zone, dns_zone):
@ -250,7 +250,7 @@ def txt_records_handler(re2o_zone, dns_zone):
txt_data
)
add_to_zone(dns_zone, name_obj, TXT_obj)
add_to_zone(dns_zone, name_obj, TXT_obj, record["ttl"])
def srv_records_handler(re2o_zone, dns_zone):
@ -272,7 +272,8 @@ def srv_records_handler(re2o_zone, dns_zone):
record["target"]
)
add_to_zone(dns_zone, name_obj, SRV_obj)
add_to_zone(dns_zone, name_obj, SRV_obj, record["ttl"])
def a_records_handler(re2o_zone, dns_zone):
"""Handler for A Record"""
@ -293,7 +294,7 @@ def a_records_handler(re2o_zone, dns_zone):
ipv4_addr
)
add_to_zone(dns_zone, name_obj, A_obj)
add_to_zone(dns_zone, name_obj, A_obj, record["ttl"])
def aaaa_records_handler(re2o_zone, dns_zone):
@ -320,7 +321,7 @@ def aaaa_records_handler(re2o_zone, dns_zone):
)
add_to_zone(dns_zone, name_obj, AAAA_obj)
add_to_zone(dns_zone, name_obj, AAAA_obj, record["ttl"])
def cname_records_handler(re2o_zone, dns_zone):
@ -339,7 +340,8 @@ def cname_records_handler(re2o_zone, dns_zone):
alias_obj
)
add_to_zone(dns_zone, name_obj, CNAME_obj)
add_to_zone(dns_zone, name_obj, CNAME_obj, record["ttl"])
def dname_records_handler(re2o_zone, dns_zone):
"""Handler for DNAME records"""
@ -357,7 +359,7 @@ def dname_records_handler(re2o_zone, dns_zone):
target_obj
)
add_to_zone(dns_zone, name_obj, DNAME_obj)
add_to_zone(dns_zone, name_obj, DNAME_obj, record["ttl"])
def pass_handler(zone, records):