don't do SSL over SSL and correctly shutdown SSL sockets.

This commit is contained in:
Yann Leboulanger 2012-08-23 11:36:51 +02:00
parent 1dc1adf073
commit fb5d58de11
1 changed files with 7 additions and 3 deletions

View File

@ -770,7 +770,10 @@ class Socks5:
if self.queue.listener.connections == []:
self.queue.listener.disconnect()
try:
self._sock.shutdown(socket.SHUT_RDWR)
if isinstance(self._sock, OpenSSL.SSL.Connection):
self._sock.shutdown()
else:
self._sock.shutdown(socket.SHUT_RDWR)
self._sock.close()
except Exception:
# socket is already closed
@ -901,7 +904,8 @@ class Socks5Sender(IdleObject):
self._sock = _sock
if _sock is not None:
if self.fingerprint is not None:
if self.fingerprint is not None and not isinstance(self._sock,
OpenSSL.SSL.Connection):
self._sock = OpenSSL.SSL.Connection(
jingle_xtls.get_context('server'), _sock)
else:
@ -938,7 +942,7 @@ class Socks5Sender(IdleObject):
if self.fingerprint is not None:
self._sock = OpenSSL.SSL.Connection(
jingle_xtls.get_context('client'), self._sock)
jingle_xtls.get_context('client'), _sock)
else:
self._sock.setblocking(False)