From 118d0d51fd61663b0903931c27dd77d806e53d5b Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Sat, 27 Aug 2016 17:29:59 +0200 Subject: [PATCH] fix crash on ShortHeader and other DNSException subclasses, fixes #247 --- nsupdate/main/dnstools.py | 1 + nsupdate/main/views.py | 2 ++ 2 files changed, 3 insertions(+) diff --git a/nsupdate/main/dnstools.py b/nsupdate/main/dnstools.py index 69a3496..ce30430 100644 --- a/nsupdate/main/dnstools.py +++ b/nsupdate/main/dnstools.py @@ -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): diff --git a/nsupdate/main/views.py b/nsupdate/main/views.py index ebed81b..b9d37f2 100644 --- a/nsupdate/main/views.py +++ b/nsupdate/main/views.py @@ -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: