fix crash on ShortHeader and other DNSException subclasses, fixes #247

This commit is contained in:
Thomas Waldmann 2016-08-27 17:29:59 +02:00
parent 60438d84fb
commit 118d0d51fd
2 changed files with 3 additions and 0 deletions

View File

@ -64,6 +64,7 @@ class FQDN(namedtuple('FQDN', ['host', 'domain'])):
Timeout = dns.resolver.Timeout
NoNameservers = dns.resolver.NoNameservers
DNSException = dns.exception.DNSException
class SameIpError(ValueError):

View File

@ -238,6 +238,8 @@ class AddHostView(CreateView):
success, level, msg = False, messages.ERROR, 'Base domain does not exist.'
except dnstools.SameIpError:
success, level, msg = False, messages.ERROR, 'Host already exists in DNS.'
except dnstools.DNSException as e:
success, level, msg = False, messages.ERROR, 'DNSException [%s]' % str(e)
except socket.error as err:
success, level, msg = False, messages.ERROR, 'Communication to name server failed [%s]' % str(err)
else: