Browse Source

display UID

dev
破娃酱 8 years ago
parent
commit
90ffd1c6ee
  1. 4
      shadowsocks/tcprelay.py
  2. 8
      shadowsocks/udprelay.py

4
shadowsocks/tcprelay.py

@ -573,9 +573,9 @@ class TCPRelayHandler(object):
data = self._handel_protocol_error(self._client_address, ogn_data) data = self._handel_protocol_error(self._client_address, ogn_data)
header_result = parse_header(data) header_result = parse_header(data)
connecttype, remote_addr, remote_port, header_length = header_result 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', ((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_address = (common.to_str(remote_addr), remote_port)
self._remote_udp = (connecttype != 0) self._remote_udp = (connecttype != 0)
# pause reading # pause reading

8
shadowsocks/udprelay.py

@ -1229,9 +1229,13 @@ class UDPRelay(object):
logging.debug('UDP port %5d sockets %d' % (self._listen_port, len(self._sockets))) 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('<I', client_uid)[0]
common.connect_log('UDP data to %s:%d via port %d by UID %d' %
(common.to_str(server_addr), server_port, (common.to_str(server_addr), server_port,
self._listen_port)) self._listen_port, user_id))
else: else:
client, client_uid = client_pair client, client_uid = client_pair
self._cache.clear(self._udp_cache_size) self._cache.clear(self._udp_cache_size)

Loading…
Cancel
Save