Proxy error handling

- UI will now display notifications in the status bar if the connection
  to the proxy itself is broken. This should give better feedback to
  people who are unfamiliar with tor and misconfigured it
- The proxy error handling in the background was slightly improved as
  well
This commit is contained in:
Peter Šurda 2016-10-20 01:46:48 +02:00
parent 7aecb4aad1
commit ab79ee2a04
Signed by untrusted user: PeterSurda
GPG Key ID: 0C5F50C0B5F37D87
3 changed files with 26 additions and 11 deletions

View File

@ -203,7 +203,16 @@ class outgoingSynSender(threading.Thread, StoppableThread):
logger.debug(str(self) + ' connected to ' + str(peer) + ' during an outgoing attempt.')
except socks.GeneralProxyError as err:
if shared.verbose >= 2:
if err[0][0] in [7, 8, 9]:
logger.error('Error communicating with proxy: %s', str(err))
shared.UISignalQueue.put((
'updateStatusBar',
tr._translate(
"MainWindow", "Problem communicating with proxy: %1. Please check your network settings.").arg(str(err[0][1]))
))
self.stop.wait(1)
continue
elif shared.verbose >= 2:
logger.debug('Could NOT connect to ' + str(peer) + ' during outgoing attempt. ' + str(err))
deletedPeer = None
@ -227,13 +236,13 @@ class outgoingSynSender(threading.Thread, StoppableThread):
except socks.Socks5AuthError as err:
shared.UISignalQueue.put((
'updateStatusBar', tr._translate(
"MainWindow", "SOCKS5 Authentication problem: %1").arg(str(err))))
"MainWindow", "SOCKS5 Authentication problem: %1. Please check your SOCKS5 settings").arg(str(err))))
except socks.Socks5Error as err:
if err[0] in [3, 4, 5, 6]:
if err[0][0] in [3, 4, 5, 6]:
# this is a more bening "error": host unreachable, network unreachable, connection refused, TTL expired
logger.debug('SOCKS5 error. ' + str(err))
logger.debug('SOCKS5 error: %s', str(err))
else:
logger.error('SOCKS5 error. ' + str(err))
logger.error('SOCKS5 error: %s', str(err))
except socks.Socks4Error as err:
logger.error('Socks4Error: ' + str(err))
except socket.error as err:

View File

@ -85,9 +85,10 @@ def dns():
sock.close()
except:
logger.error("SOCKS DNS resolving failed", exc_info=True)
if ip is not None:
logger.info ('Adding ' + ip + ' to knownNodes based on SOCKS DNS bootstrap method')
shared.knownNodes[1][shared.Peer(ip, port)] = time.time()
else:
if ip is not None:
logger.info ('Adding ' + ip + ' to knownNodes based on SOCKS DNS bootstrap method')
shared.knownNodes[1][shared.Peer(ip, port)] = time.time()
else:
logger.info('DNS bootstrap skipped because the proxy type does not support DNS resolution.')

View File

@ -64,7 +64,10 @@ _generalerrors = ("success",
"not available",
"bad proxy type",
"bad input",
"timed out")
"timed out",
"network unreachable",
"connection refused",
"host unreachable")
_socks5errors = ("succeeded",
"general SOCKS server failure",
@ -404,9 +407,11 @@ class socksocket(socket.socket):
_orgsocket.connect(self, (self.__proxy[1], portnum))
except socket.error as e:
if e[0] == 101:
raise Socks5Error((3, _socks5errors[3]))
raise GeneralProxyError((7, _generalerrors[7]))
if e[0] == 111:
raise Socks5Error((5, _socks5errors[5]))
raise GeneralProxyError((8, _generalerrors[8]))
if e[0] == 113:
raise GeneralProxyError((9, _generalerrors[9]))
raise
self.__negotiatesocks5()
self.__connectsocks5(destpair[0], destpair[1])