Socks error handling
- Socks errors are now handled in a smoother manner
This commit is contained in:
parent
f242d409fd
commit
fbed1eff31
|
@ -222,8 +222,11 @@ class outgoingSynSender(threading.Thread, StoppableThread):
|
|||
'updateStatusBar', tr._translate(
|
||||
"MainWindow", "SOCKS5 Authentication problem: %1").arg(str(err))))
|
||||
except socks.Socks5Error as err:
|
||||
pass
|
||||
logger.error('SOCKS5 error. (It is possible that the server wants authentication).) ' + str(err))
|
||||
if err[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))
|
||||
else:
|
||||
logger.error('SOCKS5 error. ' + str(err))
|
||||
except socks.Socks4Error as err:
|
||||
logger.error('Socks4Error: ' + str(err))
|
||||
except socket.error as err:
|
||||
|
|
|
@ -63,7 +63,8 @@ _generalerrors = ("success",
|
|||
"not connected",
|
||||
"not available",
|
||||
"bad proxy type",
|
||||
"bad input")
|
||||
"bad input",
|
||||
"timed out")
|
||||
|
||||
_socks5errors = ("succeeded",
|
||||
"general SOCKS server failure",
|
||||
|
@ -129,7 +130,10 @@ class socksocket(socket.socket):
|
|||
Receive EXACTLY the number of bytes requested from the socket.
|
||||
Blocks until the required number of bytes have been received.
|
||||
"""
|
||||
try:
|
||||
data = self.recv(count)
|
||||
except socket.timeout:
|
||||
raise GeneralProxyError((6, "timed out"))
|
||||
while len(data) < count:
|
||||
d = self.recv(count-len(data))
|
||||
if not d: raise GeneralProxyError((0, "connection closed unexpectedly"))
|
||||
|
@ -396,7 +400,14 @@ class socksocket(socket.socket):
|
|||
portnum = self.__proxy[2]
|
||||
else:
|
||||
portnum = 1080
|
||||
try:
|
||||
_orgsocket.connect(self, (self.__proxy[1], portnum))
|
||||
except socket.error as e:
|
||||
if e[0] == 101:
|
||||
raise Socks5Error((3, _socks5errors[3]))
|
||||
if e[0] == 111:
|
||||
raise Socks5Error((5, _socks5errors[5]))
|
||||
raise
|
||||
self.__negotiatesocks5()
|
||||
self.__connectsocks5(destpair[0], destpair[1])
|
||||
elif self.__proxy[0] == PROXY_TYPE_SOCKS4:
|
||||
|
|
Reference in New Issue
Block a user