From 90ffd1c6ee836cfc441f2b56da4c7ea8d468c07d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A0=B4=E5=A8=83=E9=85=B1?= Date: Sun, 26 Mar 2017 18:29:13 +0800 Subject: [PATCH] display UID --- shadowsocks/tcprelay.py | 4 ++-- shadowsocks/udprelay.py | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/shadowsocks/tcprelay.py b/shadowsocks/tcprelay.py index 7f01f71..817bfb2 100644 --- a/shadowsocks/tcprelay.py +++ b/shadowsocks/tcprelay.py @@ -573,9 +573,9 @@ class TCPRelayHandler(object): data = self._handel_protocol_error(self._client_address, ogn_data) header_result = parse_header(data) connecttype, remote_addr, remote_port, header_length = header_result - common.connect_log('%s connecting %s:%d via port %d' % + 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)) + common.to_str(remote_addr), remote_port, self._server._listen_port, self._user_id)) self._remote_address = (common.to_str(remote_addr), remote_port) self._remote_udp = (connecttype != 0) # pause reading diff --git a/shadowsocks/udprelay.py b/shadowsocks/udprelay.py index 3d8df3b..19f4728 100644 --- a/shadowsocks/udprelay.py +++ b/shadowsocks/udprelay.py @@ -1229,9 +1229,13 @@ class UDPRelay(object): logging.debug('UDP port %5d sockets %d' % (self._listen_port, len(self._sockets))) - common.connect_log('UDP data to %s:%d via port %d' % + if uid is None: + user_id = self._listen_port + else: + user_id = struct.unpack('