From 13ffdac2b76697f819ca2b5e21cb78079601fc66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A0=B4=E5=A8=83=E9=85=B1?= Date: Tue, 18 Oct 2016 13:36:22 +0800 Subject: [PATCH] tls1.2 split pack data --- CHANGES | 2 +- shadowsocks/obfsplugin/obfs_tls.py | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CHANGES b/CHANGES index a00c92f..116c222 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,4 @@ -2.9.5.1 2016-10-17 +2.9.6 2016-10-17 - tls1.2_ticket_auth random packet size 2.9.5.1 2016-10-16 diff --git a/shadowsocks/obfsplugin/obfs_tls.py b/shadowsocks/obfsplugin/obfs_tls.py index 691e6fa..46ecc9b 100644 --- a/shadowsocks/obfsplugin/obfs_tls.py +++ b/shadowsocks/obfsplugin/obfs_tls.py @@ -84,7 +84,14 @@ class tls_ticket_auth(plain.plain): if self.handshake_status == -1: return buf if self.handshake_status == 8: - return b"\x17" + self.tls_version + struct.pack('>H', len(buf)) + buf + ret = b'' + while len(buf) > 2048: + size = min(struct.unpack('>H', os.urandom(2))[0] % 4096 + 100, len(buf)) + ret += b"\x17" + self.tls_version + struct.pack('>H', size) + buf[:size] + buf = buf[size:] + if len(buf) > 0: + ret += b"\x17" + self.tls_version + struct.pack('>H', len(buf)) + buf + return ret self.send_buffer += b"\x17" + self.tls_version + struct.pack('>H', len(buf)) + buf if self.handshake_status == 0: self.handshake_status = 1 @@ -149,8 +156,8 @@ class tls_ticket_auth(plain.plain): return buf if self.handshake_status == 8: ret = b'' - while len(buf) > 4196: - size = struct.unpack('>H', os.urandom(2))[0] % 4096 + 100 + while len(buf) > 2048: + size = min(struct.unpack('>H', os.urandom(2))[0] % 4096 + 100, len(buf)) ret += b"\x17" + self.tls_version + struct.pack('>H', size) + buf[:size] buf = buf[size:] if len(buf) > 0: