mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-31 09:21:39 +00:00
Fix couple of minor socket issues
Set timeout and socket options on all simple sockets. At present some code paths can miss it, such as when the SSL certificate is CA-signed. Add a missing check for failure.
This commit is contained in:
parent
832369d7c4
commit
ab2f80c3e0
1 changed files with 4 additions and 3 deletions
|
@ -154,6 +154,8 @@ class TcpInterface(threading.Thread):
|
|||
try:
|
||||
s = socket.socket(res[0], socket.SOCK_STREAM)
|
||||
s.connect(res[4])
|
||||
s.settimeout(2)
|
||||
s.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)
|
||||
return s
|
||||
except BaseException as e:
|
||||
continue
|
||||
|
@ -181,6 +183,8 @@ class TcpInterface(threading.Thread):
|
|||
# get server certificate.
|
||||
# Do not use ssl.get_server_certificate because it does not work with proxy
|
||||
s = self.get_simple_socket()
|
||||
if s is None:
|
||||
return
|
||||
try:
|
||||
s = ssl.wrap_socket(s, ssl_version=ssl.PROTOCOL_SSLv23, cert_reqs=ssl.CERT_NONE, ca_certs=None)
|
||||
except ssl.SSLError, e:
|
||||
|
@ -202,9 +206,6 @@ class TcpInterface(threading.Thread):
|
|||
if s is None:
|
||||
return
|
||||
|
||||
s.settimeout(2)
|
||||
s.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)
|
||||
|
||||
if self.use_ssl:
|
||||
try:
|
||||
s = ssl.wrap_socket(s,
|
||||
|
|
Loading…
Add table
Reference in a new issue