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:]