From 59105f6e6469fc4d94e879fd4235202d237a8383 Mon Sep 17 00:00:00 2001 From: BreakWa11 Date: Mon, 26 Oct 2015 14:43:17 +0800 Subject: [PATCH] support auth_simple --- shadowsocks/obfsplugin/verify_simple.py | 22 +++++++++++++++++++++- shadowsocks/tcprelay.py | 4 ++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/shadowsocks/obfsplugin/verify_simple.py b/shadowsocks/obfsplugin/verify_simple.py index 43f8c3e..22eb787 100644 --- a/shadowsocks/obfsplugin/verify_simple.py +++ b/shadowsocks/obfsplugin/verify_simple.py @@ -338,7 +338,9 @@ class obfs_auth_data(object): def __init__(self): self.sub_obfs = None self.client_id = {} - self.startup_time = int(time.time() - 30) & 0xffffffff + self.startup_time = int(time.time() - 30) & 0xFFFFFFFF + self.local_client_id = b'' + self.connection_id = 0 def update(self, client_id, connection_id): if client_id in self.client_id: @@ -404,8 +406,26 @@ class auth_simple(verify_base): data += struct.pack(' 0xFF000000: + self.server_info.data.local_client_id = b'' + if not self.server_info.data.local_client_id: + self.server_info.data.local_client_id = os.urandom(4) + logging.debug("local_client_id %s" % (binascii.hexlify(self.server_info.data.local_client_id),)) + self.server_info.data.connection_id = struct.unpack(' self.unit_len: ret += self.pack_data(buf[:self.unit_len]) buf = buf[self.unit_len:] diff --git a/shadowsocks/tcprelay.py b/shadowsocks/tcprelay.py index f82762b..578538a 100644 --- a/shadowsocks/tcprelay.py +++ b/shadowsocks/tcprelay.py @@ -263,8 +263,8 @@ class TCPRelayHandler(object): if sock == self._local_sock and self._encrypt_correct: obfs_encode = self._obfs.server_encode(data) data = obfs_encode - l = len(data) - if l > 0: + if data: + l = len(data) s = sock.send(data) if s < l: data = data[s:]