Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/dnsviz/dnsviz.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCasey Deccio <casey@deccio.net>2021-07-28 07:22:52 +0300
committerCasey Deccio <casey@deccio.net>2021-07-28 07:27:11 +0300
commit44fc1f87660f0611507431ad09dff40cbbbacf6a (patch)
treeda643d0f81af450fa55d0c777dea41653bd52344
parent86c1f802a7b6be4d0e7927ea85c1871405463082 (diff)
Don't crash with no IPv6 support
Newer Linux kernels don't fail on bind() when there is no IPv6 support; instead they get as far as connect() before they fail. This commit modifies the error assessment after a query attempt was made, such that EADDRNOTAVAIL isn't a problem if the address was the wildcard address.
-rw-r--r--dnsviz/query.py27
1 files changed, 13 insertions, 14 deletions
diff --git a/dnsviz/query.py b/dnsviz/query.py
index 1b8cdf6..20e3d8d 100644
--- a/dnsviz/query.py
+++ b/dnsviz/query.py
@@ -1542,12 +1542,8 @@ class ExecutableDNSQuery(DNSQuery):
# If this was a network error, determine if it was a binding
# error
if err == RESPONSE_ERROR_NETWORK_ERROR:
- if errno1 == errno.EADDRNOTAVAIL:
- # Address not unavailable
- if qh._client is not None:
- raise SourceAddressBindError('Unable to bind to local address %s (%s)' % (qh._client, errno.errorcode[errno1]))
- else:
- raise SourceAddressBindError('Unable to bind to local address (%s)' % (errno.errorcode[errno1]))
+ if errno1 == errno.EADDRNOTAVAIL and qh._client is not None:
+ raise SourceAddressBindError('Unable to bind to local address %s (%s)' % (qh._client, errno.errorcode[errno1]))
elif errno1 == errno.EADDRINUSE or \
(errno1 == errno.EACCES and qtm.src is None):
# Address/port in use (EADDRINUSE) or insufficient
@@ -1556,14 +1552,17 @@ class ExecutableDNSQuery(DNSQuery):
raise PortBindError('Unable to bind to local port %d (%s)' % (qh.params['sport'], errno.errorcode[errno1]))
else:
raise PortBindError('Unable to bind to local port (%s)' % (errno.errorcode[errno1]))
- elif qtm.src is None and errno1 not in (errno.EHOSTUNREACH, errno.ENETUNREACH, errno.EAFNOSUPPORT):
- # If source is None it didn't bind properly. If the
- # errno1 value after bind() is EHOSTUNREACH or
- # ENETUNREACH, it is because there was no proper IPv4
- # or IPv6 connectivity (which is handled elsewhere).
- # If socket() failed and resulted in an errno value of
- # EAFNOSUPPORT, then likewise there is not IPv6
- # support. In other cases, it was something unknown, so
+ elif qtm.src is None and errno1 not in (errno.EHOSTUNREACH, errno.ENETUNREACH, errno.EAFNOSUPPORT, errno.EADDRNOTAVAIL):
+ # If source is None it didn't bind properly. There are several sub-cases:
+ # 1. If the bind() failed and resulted in an errno
+ # value of EHOSTUNREACH, it is because there was no
+ # proper IPv4 or IPv6 connectivity; the error for
+ # this is handled elsewhere).
+ # 2. If socket() failed and resulted in an errno value
+ # of EAFNOSUPPORT, then there is no IPv6 support.
+ # 3. If connect() failed and resulted in an errno value
+ # of EADDRNOTAVAIL, then there is no IPv6 support.
+ # In other cases, it was something unknown, so
# raise an error.
raise BindError('Unable to bind to local address (%s)' % (errno.errorcode.get(errno1, "unknown")))