close unknown socket
This commit is contained in:
parent
7599e53a6f
commit
45faa93dd3
1 changed files with 25 additions and 5 deletions
|
@ -1048,7 +1048,10 @@ class TCPRelayHandler(object):
|
||||||
self._loop.remove(sock)
|
self._loop.remove(sock)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
shell.print_exception(e)
|
shell.print_exception(e)
|
||||||
|
try:
|
||||||
del self._fd_to_handlers[sock.fileno()]
|
del self._fd_to_handlers[sock.fileno()]
|
||||||
|
except Exception as e:
|
||||||
|
shell.print_exception(e)
|
||||||
sock.close()
|
sock.close()
|
||||||
|
|
||||||
return handle
|
return handle
|
||||||
|
@ -1084,7 +1087,10 @@ class TCPRelayHandler(object):
|
||||||
self._loop.remove(self._remote_sock)
|
self._loop.remove(self._remote_sock)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
shell.print_exception(e)
|
shell.print_exception(e)
|
||||||
|
try:
|
||||||
del self._fd_to_handlers[self._remote_sock.fileno()]
|
del self._fd_to_handlers[self._remote_sock.fileno()]
|
||||||
|
except Exception as e:
|
||||||
|
shell.print_exception(e)
|
||||||
self._remote_sock.close()
|
self._remote_sock.close()
|
||||||
self._remote_sock = None
|
self._remote_sock = None
|
||||||
if self._remote_sock_v6:
|
if self._remote_sock_v6:
|
||||||
|
@ -1093,13 +1099,22 @@ class TCPRelayHandler(object):
|
||||||
self._loop.remove(self._remote_sock_v6)
|
self._loop.remove(self._remote_sock_v6)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
shell.print_exception(e)
|
shell.print_exception(e)
|
||||||
|
try:
|
||||||
del self._fd_to_handlers[self._remote_sock_v6.fileno()]
|
del self._fd_to_handlers[self._remote_sock_v6.fileno()]
|
||||||
|
except Exception as e:
|
||||||
|
shell.print_exception(e)
|
||||||
self._remote_sock_v6.close()
|
self._remote_sock_v6.close()
|
||||||
self._remote_sock_v6 = None
|
self._remote_sock_v6 = None
|
||||||
if self._local_sock:
|
if self._local_sock:
|
||||||
logging.debug('destroying local')
|
logging.debug('destroying local')
|
||||||
|
try:
|
||||||
self._loop.remove(self._local_sock)
|
self._loop.remove(self._local_sock)
|
||||||
|
except Exception as e:
|
||||||
|
shell.print_exception(e)
|
||||||
|
try:
|
||||||
del self._fd_to_handlers[self._local_sock.fileno()]
|
del self._fd_to_handlers[self._local_sock.fileno()]
|
||||||
|
except Exception as e:
|
||||||
|
shell.print_exception(e)
|
||||||
self._local_sock.close()
|
self._local_sock.close()
|
||||||
self._local_sock = None
|
self._local_sock = None
|
||||||
if self._obfs:
|
if self._obfs:
|
||||||
|
@ -1365,6 +1380,11 @@ class TCPRelay(object):
|
||||||
handler.handle_event(sock, event)
|
handler.handle_event(sock, event)
|
||||||
else:
|
else:
|
||||||
logging.warn('unknown fd')
|
logging.warn('unknown fd')
|
||||||
|
try:
|
||||||
|
self._eventloop.remove(sock)
|
||||||
|
except Exception as e:
|
||||||
|
shell.print_exception(e)
|
||||||
|
sock.close()
|
||||||
else:
|
else:
|
||||||
logging.warn('poll removed fd')
|
logging.warn('poll removed fd')
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue