From c83341da9bfb1183d5c2a0451a2e37903695cae3 Mon Sep 17 00:00:00 2001 From: BreakWa11 Date: Mon, 7 Dec 2015 13:33:42 +0800 Subject: [PATCH] add protocol_param --- config.json | 1 + shadowsocks/tcprelay.py | 19 ++++++++----------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/config.json b/config.json index 0f2a90f..d4ffc7c 100644 --- a/config.json +++ b/config.json @@ -8,6 +8,7 @@ "timeout": 120, "method": "aes-256-cfb", "protocol": "auth_sha1_compatible", + "protocol_param": "", "obfs": "http_simple_compatible", "obfs_param": "", "dns_ipv6": false, diff --git a/shadowsocks/tcprelay.py b/shadowsocks/tcprelay.py index 8953f21..1f301aa 100644 --- a/shadowsocks/tcprelay.py +++ b/shadowsocks/tcprelay.py @@ -274,15 +274,13 @@ class TCPRelayHandler(object): return True else: try: - if self._is_local: - pass - else: + if self._encrypt_correct: if sock == self._remote_sock: - if self._encrypt_correct: - self._server.server_transfer_ul += len(data) - elif self._encrypt_correct and (self._obfs is not None): - obfs_encode = self._obfs.server_encode(data) - data = obfs_encode + self._server.server_transfer_ul += len(data) + self._update_activity(len(data)) + elif not self._is_local and self._obfs is not None: + obfs_encode = self._obfs.server_encode(data) + data = obfs_encode if data: l = len(data) s = sock.send(data) @@ -597,7 +595,6 @@ class TCPRelayHandler(object): self.destroy() return ogn_data = data - self._update_activity(len(data)) if not is_local: if self._encryptor is not None: if self._encrypt_correct: @@ -667,8 +664,6 @@ class TCPRelayHandler(object): self.destroy() return if self._encryptor is not None: - self._server.server_transfer_dl += len(data) - self._update_activity(len(data)) if self._is_local: obfs_decode = self._obfs.client_decode(data) if obfs_decode[1]: @@ -683,6 +678,8 @@ class TCPRelayHandler(object): if self._encrypt_correct: data = self._protocol.server_pre_encrypt(data) data = self._encryptor.encrypt(data) + self._update_activity(len(data)) + self._server.server_transfer_dl += len(data) else: return try: