Merge pull request #254 from elnappo/check_domain_fixes

fixes #246, #249, #253
This commit is contained in:
TW 2016-01-26 14:37:03 +01:00
commit d3451be2ea
3 changed files with 10 additions and 6 deletions

View File

@ -23,6 +23,8 @@ zone nsupdate.info {
deny nsupdate.info. name www.nsupdate.info; deny nsupdate.info. name www.nsupdate.info;
deny nsupdate.info. name ipv4.nsupdate.info; deny nsupdate.info. name ipv4.nsupdate.info;
deny nsupdate.info. name ipv6.nsupdate.info; deny nsupdate.info. name ipv6.nsupdate.info;
// this host is for testing if the nameserver is configured correctly and reachable
grant nsupdate.info. name connectivity-test.nsupdate.info A;
// but we allow updates to any other host: // but we allow updates to any other host:
grant nsupdate.info. subdomain nsupdate.info; grant nsupdate.info. subdomain nsupdate.info;
}; };

View File

@ -24,6 +24,8 @@ import logging
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
import socket import socket
import random
import struct
import dns.inet import dns.inet
import dns.name import dns.name
@ -104,18 +106,16 @@ def check_domain(domain):
from .models import Domain from .models import Domain
d = Domain.objects.get(name=domain) d = Domain.objects.get(name=domain)
# temporarily set domain to available # temporarily set domain to available to allow add/update/deletes
domain_available_state = d.available domain_available_state = d.available
d.available = True d.available = True
d.save() d.save()
try: try:
# add to primary # add host connectivity-test.<domain> with a random IP. See add()
add(fqdn, "8.8.8.8") add(fqdn, socket.inet_ntoa(struct.pack('>I', random.randint(1, 0xffffffff))))
# delete on primary
delete(fqdn)
except (dns.exception.DNSException, ) as e: except (dns.exception.DNSException, DnsUpdateError) as e:
raise NameServerNotAvailable(str(e)) raise NameServerNotAvailable(str(e))
finally: finally:

View File

@ -42,6 +42,8 @@ zone {{ object.name }} {
deny {{ object.name }}. name www.{{ object.name }}; deny {{ object.name }}. name www.{{ object.name }};
deny {{ object.name }}. name ipv4.{{ object.name }}; deny {{ object.name }}. name ipv4.{{ object.name }};
deny {{ object.name }}. name ipv6.{{ object.name }}; deny {{ object.name }}. name ipv6.{{ object.name }};
// this host is for testing if the nameserver is configured correctly and reachable
grant {{ object.name }}. name connectivity-test.{{ object.name }} A;
// but we allow updates to any other host: // but we allow updates to any other host:
grant {{ object.name }}. subdomain {{ object.name }}; grant {{ object.name }}. subdomain {{ object.name }};
}; };