XTLS: Fix endless loop on write error

This commit is contained in:
Philipp Hörist 2019-02-15 14:58:56 +01:00
parent 9419e8ddf7
commit 05f1c78098
1 changed files with 10 additions and 5 deletions

View File

@ -687,13 +687,11 @@ class Socks5:
OpenSSL.SSL.WantX509LookupError) as e:
log.info('SSL rehandshake request: %s', repr(e))
raise e
except OpenSSL.SSL.SysCallError:
return self._on_send_exception()
except Exception as e:
if e.errno not in (EINTR, ENOBUFS, EWOULDBLOCK):
# peer stopped reading
self.state = 8 # end connection
self.disconnect()
self.file_props.error = -1
return -1
return self._on_send_exception()
self.size += lenn
current_time = time.time()
self.file_props.elapsed_time += current_time - \
@ -719,6 +717,13 @@ class Socks5:
self.disconnect()
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):
"""
Read file contents from socket and write them to file