From 582d7b72564e8b38f276309951ff19069ca5214d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A0=B4=E5=A8=83=E9=85=B1?= Date: Thu, 27 Apr 2017 21:28:23 +0800 Subject: [PATCH] connect_log include local addr & port --- shadowsocks/tcprelay.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/shadowsocks/tcprelay.py b/shadowsocks/tcprelay.py index dbc428a..2687a73 100644 --- a/shadowsocks/tcprelay.py +++ b/shadowsocks/tcprelay.py @@ -596,9 +596,12 @@ class TCPRelayHandler(object): server_info = self._protocol.get_server_info() server_info.buffer_size = self._recv_buffer_size connecttype, remote_addr, remote_port, header_length = header_result - common.connect_log('%s connecting %s:%d via port %d by UID %d' % - ((connecttype == 0) and 'TCP' or 'UDP', - common.to_str(remote_addr), remote_port, self._server._listen_port, self._user_id)) + if connecttype != 0: + common.connect_log('UDP over TCP by user %d' % + (self._user_id, )) + else: + common.connect_log('TCP request %s:%d by user %d' % + (common.to_str(remote_addr), remote_port, self._user_id)) self._remote_address = (common.to_str(remote_addr), remote_port) self._remote_udp = (connecttype != 0) # pause reading @@ -746,6 +749,10 @@ class TCPRelayHandler(object): pass # always goto here else: raise e + addr, port = self._remote_sock.getsockname()[:2] + common.connect_log('TCP connecting %s(%s):%d from %s:%d by user %d' % + (self._remote_address[0], remote_addr, remote_port, addr, port, self._user_id)) + self._loop.add(remote_sock, eventloop.POLL_ERR | eventloop.POLL_OUT, self._server)