Log network errors a little more carefully.
This commit is contained in:
parent
71f8a3dc86
commit
bd7c5c2110
33
av98.py
33
av98.py
|
@ -404,18 +404,7 @@ Slow internet connection? Use 'set timeout' to be more patient.""")
|
|||
continue
|
||||
|
||||
# Send request to server
|
||||
try:
|
||||
status, meta, address, f = self._send_request(gi)
|
||||
except Exception as err:
|
||||
if isinstance(err, socket.gaierror):
|
||||
self.log["dns_failures"] += 1
|
||||
elif isinstance(err, ConnectionRefusedError):
|
||||
self.log["refused_connections"] += 1
|
||||
elif isinstance(err, ConnectionResetError):
|
||||
self.log["reset_connections"] += 1
|
||||
elif isinstance(err, (TimeoutError, socket.timeout)):
|
||||
self.log["timeouts"] += 1
|
||||
raise err
|
||||
status, meta, address, f = self._send_request(gi)
|
||||
|
||||
# Update redirect loop/maze escaping state
|
||||
if not status.startswith("3"):
|
||||
|
@ -552,7 +541,12 @@ Slow internet connection? Use 'set timeout' to be more patient.""")
|
|||
self.client_certs.pop(gi.host)
|
||||
|
||||
# Do DNS resolution
|
||||
addresses = self._get_addresses(host, port)
|
||||
try:
|
||||
addresses = self._get_addresses(host, port)
|
||||
except Exception as err:
|
||||
if isinstance(err, socket.gaierror):
|
||||
self.log["dns_failures"] += 1
|
||||
raise err
|
||||
|
||||
# Prepare TLS context
|
||||
def _newest_supported_protocol():
|
||||
|
@ -604,12 +598,19 @@ Slow internet connection? Use 'set timeout' to be more patient.""")
|
|||
try:
|
||||
s.connect(address[4])
|
||||
break
|
||||
except OSError as e:
|
||||
except Exception as e:
|
||||
err = e
|
||||
# Log network errors
|
||||
if isinstance(err, ConnectionRefusedError):
|
||||
self.log["refused_connections"] += 1
|
||||
elif isinstance(err, ConnectionResetError):
|
||||
self.log["reset_connections"] += 1
|
||||
elif isinstance(err, (TimeoutError, socket.timeout)):
|
||||
self.log["timeouts"] += 1
|
||||
else:
|
||||
# If we couldn't connect to *any* of the addresses, just
|
||||
# bubble up the exception from the last attempt and deny
|
||||
# knowledge of earlier failures.
|
||||
# bubble up the exception from the last attempt for the
|
||||
# sake of error reporting to the user.
|
||||
raise err
|
||||
|
||||
if sys.version_info.minor >=5:
|
||||
|
|
Loading…
Reference in New Issue