Skip to content
Snippets Groups Projects
Commit 05f1c780 authored by Philipp Hörist's avatar Philipp Hörist
Browse files

XTLS: Fix endless loop on write error

parent 9419e8dd
No related branches found
No related tags found
No related merge requests found
...@@ -687,13 +687,11 @@ class Socks5: ...@@ -687,13 +687,11 @@ class Socks5:
OpenSSL.SSL.WantX509LookupError) as e: OpenSSL.SSL.WantX509LookupError) as e:
log.info('SSL rehandshake request: %s', repr(e)) log.info('SSL rehandshake request: %s', repr(e))
raise e raise e
except OpenSSL.SSL.SysCallError:
return self._on_send_exception()
except Exception as e: except Exception as e:
if e.errno not in (EINTR, ENOBUFS, EWOULDBLOCK): if e.errno not in (EINTR, ENOBUFS, EWOULDBLOCK):
# peer stopped reading return self._on_send_exception()
self.state = 8 # end connection
self.disconnect()
self.file_props.error = -1
return -1
self.size += lenn self.size += lenn
current_time = time.time() current_time = time.time()
self.file_props.elapsed_time += current_time - \ self.file_props.elapsed_time += current_time - \
...@@ -719,6 +717,13 @@ class Socks5: ...@@ -719,6 +717,13 @@ class Socks5:
self.disconnect() self.disconnect()
return -1 return -1
def _on_send_exception(self):
# peer stopped reading
self.state = 8 # end connection
self.disconnect()
self.file_props.error = -1
return -1
def get_file_contents(self, timeout): def get_file_contents(self, timeout):
""" """
Read file contents from socket and write them to file Read file contents from socket and write them to file
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment