work around UnknownTSIGKey exception blowing up the overview view

This commit is contained in:
Thomas Waldmann 2018-04-25 16:25:34 +02:00
parent a70e9d01c5
commit 92c105b64c
2 changed files with 5 additions and 2 deletions

View File

@ -28,6 +28,7 @@ import random
import struct
import dns.inet
import dns.message
import dns.name
import dns.resolver
import dns.query
@ -256,7 +257,7 @@ def query_ns(fqdn, rdtype, prefer_primary=False):
ip = str(list(answer)[0])
logger.debug("query: %s answer: %s" % (fqdn, ip))
return ip
except (dns.resolver.Timeout, dns.resolver.NoNameservers) as e: # socket.error also?
except (dns.resolver.Timeout, dns.resolver.NoNameservers, dns.message.UnknownTSIGKey) as e: # socket.error also?
logger.warning("error when querying for name '%s' in zone '%s' with rdtype '%s' [%s]." % (
fqdn.host, origin, rdtype, str(e)))
set_ns_availability(origin, False)

View File

@ -7,6 +7,7 @@ import time
import base64
import dns.resolver
import dns.message
from django.db import models
from django.contrib.auth import get_user_model
@ -288,7 +289,8 @@ class Host(models.Model):
return dnstools.query_ns(self.get_fqdn(), record)
except (dns.resolver.NXDOMAIN, dns.resolver.NoAnswer):
return None
except (dns.resolver.NoNameservers, dns.resolver.Timeout, dnstools.NameServerNotAvailable):
except (dns.resolver.NoNameservers, dns.resolver.Timeout, dnstools.NameServerNotAvailable,
dns.message.UnknownTSIGKey):
return _('error')
def get_ipv4(self):