def _handle_channel(self, sock):
"""
Create a channel in the Tunnel to accommodate new SOCKS client, and proxy data to/from the SOCKS client
through the tunnel.
:param socket.socket sock: A newly connect SOCKS client
"""
host, port = sock.getpeername()[:2]
try:
channel = self.tunnel.open_channel(self.channel_counter.__next__(), open_remote=True, exc=True)
except ValueError as e:
self.logger.error('Error occurred while opening channel: {}'.format(e))
sock.close()
return
self.tunnel.proxy_sock_channel(sock, channel, self.logger)
self.logger.info('Terminating thread that handled {} <--> {}:{}'.format(channel, host, port))
评论列表
文章目录