Initial backend changes to make it possible to have one or more secondary name servers

This commit is contained in:
Brian Bustin 2015-07-01 15:02:40 -04:00
parent c0ddceb2bd
commit e1a545d9d4
1 changed files with 15 additions and 6 deletions

View File

@ -144,6 +144,11 @@ def build_zone(domain, all_domains, additional_records, www_redirect_domains, en
records.append((None, "NS", "ns1.%s." % env["PRIMARY_HOSTNAME"], False)) records.append((None, "NS", "ns1.%s." % env["PRIMARY_HOSTNAME"], False))
# Define ns2.PRIMARY_HOSTNAME or whatever the user overrides. # Define ns2.PRIMARY_HOSTNAME or whatever the user overrides.
# User may provide one or more additional nameservers
if get_secondary_dns(additional_records).len > 0:
for secondary_ns in get_secondary_dns(additional_records):
records.append((None, "NS", secondary_ns+'.', False))
else:
secondary_ns = get_secondary_dns(additional_records) or ("ns2." + env["PRIMARY_HOSTNAME"]) secondary_ns = get_secondary_dns(additional_records) or ("ns2." + env["PRIMARY_HOSTNAME"])
records.append((None, "NS", secondary_ns+'.', False)) records.append((None, "NS", secondary_ns+'.', False))
@ -462,9 +467,9 @@ zone:
zonefile: %s zonefile: %s
""" % (domain, zonefile) """ % (domain, zonefile)
# If a custom secondary nameserver has been set, allow zone transfers # If a custom secondary nameservers have been set, allow zone transfers
# and notifies to that nameserver. # and notifies to th.
if get_secondary_dns(additional_records): for secondary_ns in get_secondary_dns(additional_records):
# Get the IP address of the nameserver by resolving it. # Get the IP address of the nameserver by resolving it.
hostname = get_secondary_dns(additional_records) hostname = get_secondary_dns(additional_records)
resolver = dns.resolver.get_default_resolver() resolver = dns.resolver.get_default_resolver()
@ -793,6 +798,10 @@ def set_custom_dns_record(qname, rtype, value, action, env):
def get_secondary_dns(custom_dns): def get_secondary_dns(custom_dns):
for qname, rtype, value in custom_dns: for qname, rtype, value in custom_dns:
if qname == "_secondary_nameserver": if qname == "_secondary_nameserver":
# always return a list so other parts of code path can iterate
if isinstance(value, str):
return [value]
else:
return value return value
return None return None