diff --git a/shadowsocks/tcprelay.py b/shadowsocks/tcprelay.py index 395ecbf..028e33d 100644 --- a/shadowsocks/tcprelay.py +++ b/shadowsocks/tcprelay.py @@ -268,7 +268,7 @@ class TCPRelayHandler(object): if self._is_local: pass else: - if sock == self._local_sock and self._encrypt_correct: + if sock == self._local_sock and self._encrypt_correct and (self._obfs is not None): obfs_encode = self._obfs.server_encode(data) data = obfs_encode if data: @@ -338,9 +338,10 @@ class TCPRelayHandler(object): def _handle_stage_connecting(self, data): if self._is_local: - data = self._protocol.client_pre_encrypt(data) - data = self._encryptor.encrypt(data) - data = self._obfs.client_encode(data) + if self._encryptor is not None: + data = self._protocol.client_pre_encrypt(data) + data = self._encryptor.encrypt(data) + data = self._obfs.client_encode(data) if data: self._data_to_write_to_remote.append(data) if self._is_local and not self._fastopen_connected and \ @@ -436,9 +437,10 @@ class TCPRelayHandler(object): data = b'\x88' + struct.pack('>H', total_len) + chr(rnd_len) + (b' ' * (rnd_len - 1)) + data crc = (0xffffffff - binascii.crc32(data)) & 0xffffffff data += struct.pack('