|  |  | @ -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,6 +338,7 @@ class TCPRelayHandler(object): | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     def _handle_stage_connecting(self, data): | 
			
		
	
		
			
				
					|  |  |  |         if self._is_local: | 
			
		
	
		
			
				
					|  |  |  |             if self._encryptor is not None: | 
			
		
	
		
			
				
					|  |  |  |                 data = self._protocol.client_pre_encrypt(data) | 
			
		
	
		
			
				
					|  |  |  |                 data = self._encryptor.encrypt(data) | 
			
		
	
		
			
				
					|  |  |  |                 data = self._obfs.client_encode(data) | 
			
		
	
	
		
			
				
					|  |  | @ -436,6 +437,7 @@ 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('<I', crc) | 
			
		
	
		
			
				
					|  |  |  |                 if self._encryptor is not None: | 
			
		
	
		
			
				
					|  |  |  |                     data = self._protocol.client_pre_encrypt(data) | 
			
		
	
		
			
				
					|  |  |  |                     data_to_send = self._encryptor.encrypt(data) | 
			
		
	
		
			
				
					|  |  |  |                     data_to_send = self._obfs.client_encode(data_to_send) | 
			
		
	
	
		
			
				
					|  |  | @ -573,6 +575,7 @@ class TCPRelayHandler(object): | 
			
		
	
		
			
				
					|  |  |  |         ogn_data = data | 
			
		
	
		
			
				
					|  |  |  |         self._update_activity(len(data)) | 
			
		
	
		
			
				
					|  |  |  |         if not is_local: | 
			
		
	
		
			
				
					|  |  |  |             if self._encryptor is not None: | 
			
		
	
		
			
				
					|  |  |  |                 if self._encrypt_correct: | 
			
		
	
		
			
				
					|  |  |  |                     obfs_decode = self._obfs.server_decode(data) | 
			
		
	
		
			
				
					|  |  |  |                     if obfs_decode[2]: | 
			
		
	
	
		
			
				
					|  |  | @ -586,11 +589,14 @@ class TCPRelayHandler(object): | 
			
		
	
		
			
				
					|  |  |  |                     except Exception as e: | 
			
		
	
		
			
				
					|  |  |  |                         shell.print_exception(e) | 
			
		
	
		
			
				
					|  |  |  |                         self.destroy() | 
			
		
	
		
			
				
					|  |  |  |             else: | 
			
		
	
		
			
				
					|  |  |  |                 return | 
			
		
	
		
			
				
					|  |  |  |             if not data: | 
			
		
	
		
			
				
					|  |  |  |                 return | 
			
		
	
		
			
				
					|  |  |  |         self._server.server_transfer_ul += len(data) | 
			
		
	
		
			
				
					|  |  |  |         if self._stage == STAGE_STREAM: | 
			
		
	
		
			
				
					|  |  |  |             if self._is_local: | 
			
		
	
		
			
				
					|  |  |  |                 if self._encryptor is not None: | 
			
		
	
		
			
				
					|  |  |  |                     data = self._protocol.client_pre_encrypt(data) | 
			
		
	
		
			
				
					|  |  |  |                     data = self._encryptor.encrypt(data) | 
			
		
	
		
			
				
					|  |  |  |                     data = self._obfs.client_encode(data) | 
			
		
	
	
		
			
				
					|  |  | @ -634,6 +640,7 @@ class TCPRelayHandler(object): | 
			
		
	
		
			
				
					|  |  |  |         if not data: | 
			
		
	
		
			
				
					|  |  |  |             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: | 
			
		
	
	
		
			
				
					|  |  | @ -647,6 +654,8 @@ class TCPRelayHandler(object): | 
			
		
	
		
			
				
					|  |  |  |                 if self._encrypt_correct: | 
			
		
	
		
			
				
					|  |  |  |                     data = self._protocol.server_pre_encrypt(data) | 
			
		
	
		
			
				
					|  |  |  |                     data = self._encryptor.encrypt(data) | 
			
		
	
		
			
				
					|  |  |  |         else: | 
			
		
	
		
			
				
					|  |  |  |             return | 
			
		
	
		
			
				
					|  |  |  |         try: | 
			
		
	
		
			
				
					|  |  |  |             self._write_to_sock(data, self._local_sock) | 
			
		
	
		
			
				
					|  |  |  |         except Exception as e: | 
			
		
	
	
		
			
				
					|  |  | @ -770,6 +779,7 @@ class TCPRelayHandler(object): | 
			
		
	
		
			
				
					|  |  |  |         if self._protocol: | 
			
		
	
		
			
				
					|  |  |  |             self._protocol.dispose() | 
			
		
	
		
			
				
					|  |  |  |             self._protocol = None | 
			
		
	
		
			
				
					|  |  |  |         self._encryptor = None | 
			
		
	
		
			
				
					|  |  |  |         self._dns_resolver.remove_callback(self._handle_dns_resolved) | 
			
		
	
		
			
				
					|  |  |  |         self._server.remove_handler(self) | 
			
		
	
		
			
				
					|  |  |  |         self._server.add_connection(-1) | 
			
		
	
	
		
			
				
					|  |  | 
 |