This commit is contained in:
Charlie Jacomme 2018-08-08 19:00:59 +02:00
commit 7918566fd0

18
main.py
View file

@ -14,7 +14,7 @@ api_password = config.get('Re2o', 'password')
api_username = config.get('Re2o', 'username')
template_soa = ("$ORIGIN {zone}.\n"
"@ IN SOA {ns} {mail} (\n"
"@ IN SOA {ns}. {mail} (\n"
" {serial} ; serial\n"
" {refresh} ; refresh\n"
" {retry} ; retry\n"
@ -23,14 +23,14 @@ template_soa = ("$ORIGIN {zone}.\n"
")")
template_originv4 = "@ IN A {ipv4}"
template_originv6 = "@ IN AAAA {ipv6}"
template_ns = "@ IN NS {target}"
template_mx = "@ IN MX {priority} {target}"
template_ns = "@ IN NS {target}."
template_mx = "@ IN MX {priority} {target}."
template_txt = "{field1} IN TXT {field2}"
template_srv = "_{service}._{protocol}.{zone} {ttl} IN SRV {priority} {weight} {port} {target}"
template_a = "{hostname} IN A {ipv4}"
template_aaaa = "{hostname} IN AAAA {ipv6}"
template_cname = "{hostname} IN CNAME {alias}"
template_ptr = "{target} IN PTR {hostname}"
template_cname = "{hostname} IN CNAME {alias}."
template_ptr = "{target} IN PTR {hostname}."
template_zone = ("$TTL 2D\n"
"{soa}\n"
@ -138,7 +138,7 @@ def write_dns_files(api_client):
cname_records = "\n".join(
template_cname.format(hostname=x['hostname'],
alias=x['alias'],extension=x['extension'])
alias=x['alias'])
for x in zone['cname_records']
)
@ -262,7 +262,7 @@ def write_dns_reverse_file(api_client):
net_class = max(((net.prefixlen - 1) // 4) + 1, 1)
zone6_name = ".".join(
netaddr.IPAddress(net.first).reverse_dns.split('.')[32 - net_class:]
)
)[:-1]
soa = template_soa.format(zone=zone6_name,
@ -288,7 +288,7 @@ def write_dns_reverse_file(api_client):
ptr_records = ptr_records)
filename = 'generated/dns.{zone}zone'.format(zone=zone6_name)
filename = 'generated/dns.{zone}.zone'.format(zone=zone6_name)
with open(filename, 'a') as f:
f.write(zone_file_content)
else:
@ -299,7 +299,7 @@ def write_dns_reverse_file(api_client):
ptr_records = ptr_records)
filename = 'generated/dns.{zone}zone'.format(zone=zone6_name)
filename = 'generated/dns.{zone}.zone'.format(zone=zone6_name)
with open(filename, 'w+') as f:
f.write(zone_file_content)
zone_v6.append(zone6_name)