mirror of
https://github.com/mail-in-a-box/mailinabox.git
synced 2024-12-24 07:37:04 +00:00
Secondary nameservers: Allow IPv6
This commit is contained in:
parent
211d3ff8a8
commit
235ebe9a4a
@ -905,6 +905,8 @@ def set_secondary_dns(hostnames, env):
|
|||||||
# Resolve hostname.
|
# Resolve hostname.
|
||||||
try:
|
try:
|
||||||
response = resolver.query(item, "A")
|
response = resolver.query(item, "A")
|
||||||
|
except (dns.resolver.NoNameservers, dns.resolver.NXDOMAIN, dns.resolver.NoAnswer):
|
||||||
|
response = resolver.query(item, "AAAA")
|
||||||
except (dns.resolver.NoNameservers, dns.resolver.NXDOMAIN, dns.resolver.NoAnswer):
|
except (dns.resolver.NoNameservers, dns.resolver.NXDOMAIN, dns.resolver.NoAnswer):
|
||||||
raise ValueError("Could not resolve the IP address of %s." % item)
|
raise ValueError("Could not resolve the IP address of %s." % item)
|
||||||
else:
|
else:
|
||||||
@ -912,12 +914,14 @@ def set_secondary_dns(hostnames, env):
|
|||||||
try:
|
try:
|
||||||
if "/" in item[4:]:
|
if "/" in item[4:]:
|
||||||
v = ipaddress.ip_network(item[4:]) # raises a ValueError if there's a problem
|
v = ipaddress.ip_network(item[4:]) # raises a ValueError if there's a problem
|
||||||
if not isinstance(v, ipaddress.IPv4Network): raise ValueError("That's an IPv6 subnet.")
|
if not isinstance(v, ipaddress.IPv4Network) and not isinstance(v, ipaddress.IPv6Network):
|
||||||
|
raise ValueError("That's neither an IPv4 or IPv6 subnet.")
|
||||||
else:
|
else:
|
||||||
v = ipaddress.ip_address(item[4:]) # raises a ValueError if there's a problem
|
v = ipaddress.ip_address(item[4:]) # raises a ValueError if there's a problem
|
||||||
if not isinstance(v, ipaddress.IPv4Address): raise ValueError("That's an IPv6 address.")
|
if not isinstance(v, ipaddress.IPv4Network) and not isinstance(v, ipaddress.IPv6Network):
|
||||||
|
raise ValueError("That's neither an IPv4 or IPv6 address.")
|
||||||
except ValueError:
|
except ValueError:
|
||||||
raise ValueError("'%s' is not an IPv4 address or subnet." % item[4:])
|
raise ValueError("'%s' is not an IPv4 or IPv6 address or subnet." % item[4:])
|
||||||
|
|
||||||
# Set.
|
# Set.
|
||||||
set_custom_dns_record("_secondary_nameserver", "A", " ".join(hostnames), "set", env)
|
set_custom_dns_record("_secondary_nameserver", "A", " ".join(hostnames), "set", env)
|
||||||
|
Loading…
Reference in New Issue
Block a user