Add support for record-level TTL
This commit is contained in:
parent
80ae6c7760
commit
fe4307f402
1 changed files with 13 additions and 11 deletions
24
lib.py
24
lib.py
|
@ -52,7 +52,7 @@ def format_re2o_domain(name: str):
|
||||||
|
|
||||||
return name_obj
|
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."""
|
"""Add a rdata object to a zone object."""
|
||||||
|
|
||||||
node = zone.find_node(name, create=True)
|
node = zone.find_node(name, create=True)
|
||||||
|
@ -61,7 +61,7 @@ def add_to_zone(zone, name, rdata):
|
||||||
rdata.rdtype,
|
rdata.rdtype,
|
||||||
create=True
|
create=True
|
||||||
)
|
)
|
||||||
rdataset.add(rdata)
|
rdataset.add(rdata, ttl=ttl)
|
||||||
|
|
||||||
|
|
||||||
def get_serial(dns_zone):
|
def get_serial(dns_zone):
|
||||||
|
@ -170,7 +170,7 @@ def ns_records_handler(re2o_zone, dns_zone):
|
||||||
target_obj
|
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):
|
def sshfp_record_handler(re2o_zone, dns_zone):
|
||||||
|
@ -199,7 +199,7 @@ def sshfp_record_handler(re2o_zone, dns_zone):
|
||||||
fingerprint,
|
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):
|
def mx_records_handler(re2o_zone, dns_zone):
|
||||||
|
@ -221,7 +221,7 @@ def mx_records_handler(re2o_zone, dns_zone):
|
||||||
exchange_obj
|
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):
|
def txt_records_handler(re2o_zone, dns_zone):
|
||||||
|
@ -250,7 +250,7 @@ def txt_records_handler(re2o_zone, dns_zone):
|
||||||
txt_data
|
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):
|
def srv_records_handler(re2o_zone, dns_zone):
|
||||||
|
@ -272,7 +272,8 @@ def srv_records_handler(re2o_zone, dns_zone):
|
||||||
record["target"]
|
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):
|
def a_records_handler(re2o_zone, dns_zone):
|
||||||
"""Handler for A Record"""
|
"""Handler for A Record"""
|
||||||
|
@ -293,7 +294,7 @@ def a_records_handler(re2o_zone, dns_zone):
|
||||||
ipv4_addr
|
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):
|
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):
|
def cname_records_handler(re2o_zone, dns_zone):
|
||||||
|
@ -339,7 +340,8 @@ def cname_records_handler(re2o_zone, dns_zone):
|
||||||
alias_obj
|
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):
|
def dname_records_handler(re2o_zone, dns_zone):
|
||||||
"""Handler for DNAME records"""
|
"""Handler for DNAME records"""
|
||||||
|
@ -357,7 +359,7 @@ def dname_records_handler(re2o_zone, dns_zone):
|
||||||
target_obj
|
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):
|
def pass_handler(zone, records):
|
||||||
|
|
Loading…
Reference in a new issue