Initial backend changes to make it possible to have one or more secondary name servers
This commit is contained in:
parent
c0ddceb2bd
commit
e1a545d9d4
|
@ -144,8 +144,13 @@ 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.
|
||||||
secondary_ns = get_secondary_dns(additional_records) or ("ns2." + env["PRIMARY_HOSTNAME"])
|
# User may provide one or more additional nameservers
|
||||||
records.append((None, "NS", secondary_ns+'.', False))
|
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"])
|
||||||
|
records.append((None, "NS", secondary_ns+'.', False))
|
||||||
|
|
||||||
|
|
||||||
# In PRIMARY_HOSTNAME...
|
# In PRIMARY_HOSTNAME...
|
||||||
|
@ -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,7 +798,11 @@ 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":
|
||||||
return value
|
# always return a list so other parts of code path can iterate
|
||||||
|
if isinstance(value, str):
|
||||||
|
return [value]
|
||||||
|
else:
|
||||||
|
return value
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def set_secondary_dns(hostname, env):
|
def set_secondary_dns(hostname, env):
|
||||||
|
|
Loading…
Reference in New Issue