From f31a81665cb0c12878fd6baf3d1c85bb88494c60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A0=B4=E5=A8=83=E9=85=B1?= Date: Tue, 30 May 2017 21:32:51 +0800 Subject: [PATCH] refine UDP over TCP --- shadowsocks/tcprelay.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/shadowsocks/tcprelay.py b/shadowsocks/tcprelay.py index 661f359..f401276 100644 --- a/shadowsocks/tcprelay.py +++ b/shadowsocks/tcprelay.py @@ -347,15 +347,11 @@ class TCPRelayHandler(object): #logging.info('UDP over TCP sendto %d %s' % (len(data), binascii.hexlify(data))) while len(self._udp_data_send_buffer) > 6: length = struct.unpack('>H', self._udp_data_send_buffer[:2])[0] - if length >= 0xff00: - length = struct.unpack('>H', self._udp_data_send_buffer[1:3])[0] + 0xff00 if length > len(self._udp_data_send_buffer): break data = self._udp_data_send_buffer[:length] - if length >= 0xff00: - data = data[1:] self._udp_data_send_buffer = self._udp_data_send_buffer[length:] frag = common.ord(data[2]) @@ -953,10 +949,7 @@ class TCPRelayHandler(object): ip = socket.inet_pton(socket.AF_INET6, addr[0]) data = b'\x00\x04' + ip + port + data size = len(data) + 2 - if size >= 0xff00: - data = common.chr(0xff) + struct.pack('>H', size - 0xff00 + 1) + data - else: - data = struct.pack('>H', size) + data + data = struct.pack('>H', size) + data #logging.info('UDP over TCP recvfrom %s:%d %d bytes to %s:%d' % (addr[0], addr[1], len(data), self._client_address[0], self._client_address[1])) else: if self._is_local: