Fixed native client code
This commit is contained in:
		
							parent
							
								
									ca8b46b590
								
							
						
					
					
						commit
						93cf160be3
					
				| @ -72,7 +72,7 @@ void ProtocolHandler::connect() { | ||||
| 	{ | ||||
| 		auto command = this->generate_client_initiv(); | ||||
| 		auto packet = make_shared<ClientPacket>(PacketTypeInfo::Command, pipes::buffer_view{command.data(), command.size()}); | ||||
| 		packet->enableFlag(PacketFlag::NewProtocol); | ||||
| 		packet->enable_flag(PacketFlag::NewProtocol); | ||||
| 		this->send_packet(packet); | ||||
| 	} | ||||
| } | ||||
| @ -186,9 +186,9 @@ void ProtocolHandler::progress_packet(const pipes::buffer_view &buffer) { | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	packet->setEncrypted(!packet->hasFlag(PacketFlag::Unencrypted)); | ||||
| 	packet->setEncrypted(!packet->has_flag(PacketFlag::Unencrypted)); | ||||
| 	if(packet->type() == PacketTypeInfo::Command || packet->type() == PacketTypeInfo::CommandLow){ | ||||
| 		packet->setCompressed(packet->hasFlag(PacketFlag::Compressed)); | ||||
| 		packet->setCompressed(packet->has_flag(PacketFlag::Compressed)); | ||||
| 	} | ||||
| 	//NOTICE I found out that the Compressed flag is set if the packet contains an audio header
 | ||||
| 
 | ||||
| @ -209,7 +209,7 @@ void ProtocolHandler::progress_packet(const pipes::buffer_view &buffer) { | ||||
| 	} | ||||
| 
 | ||||
| 	if(packet->type() == PacketTypeInfo::Command || packet->type() == PacketTypeInfo::CommandLow){ | ||||
| 		if(packet->hasFlag(PacketFlag::Unencrypted)) | ||||
| 		if(packet->has_flag(PacketFlag::Unencrypted)) | ||||
| 			return; | ||||
| 	} | ||||
| 
 | ||||
| @ -281,7 +281,7 @@ bool ProtocolHandler::handle_packets() { | ||||
| 		current_packet = buffer->slot_value(sequence_length++); | ||||
| 
 | ||||
| 		if(current_packet) { | ||||
| 			if((current_packet->type() == PacketTypeInfo::Command || current_packet->type() == PacketTypeInfo::CommandLow) && current_packet->hasFlag(PacketFlag::Fragmented)) { | ||||
| 			if((current_packet->type() == PacketTypeInfo::Command || current_packet->type() == PacketTypeInfo::CommandLow) && current_packet->has_flag(PacketFlag::Fragmented)) { | ||||
| 				do { | ||||
| 					if(sequence_length >= buffer->capacity()) { | ||||
| 						log_warn(category::connection, tr("Received fragmented packets which have a too long order. Dropping queue, which will cause a client drop.")); | ||||
| @ -289,7 +289,7 @@ bool ProtocolHandler::handle_packets() { | ||||
| 						return false; | ||||
| 					} | ||||
| 					current_packet = buffer->slot_value(sequence_length++); | ||||
| 				} while(current_packet && !current_packet->hasFlag(PacketFlag::Fragmented)); | ||||
| 				} while(current_packet && !current_packet->has_flag(PacketFlag::Fragmented)); | ||||
| 			} | ||||
| 		} else { | ||||
| 			log_critical(category::connection, tr("buffer->slot_value(sequence_length++) returned nullptr!")); | ||||
| @ -314,7 +314,7 @@ bool ProtocolHandler::handle_packets() { | ||||
| 					} | ||||
| 
 | ||||
| 					append.push_back(packet->data()); | ||||
| 					if(packet->hasFlag(PacketFlag::Fragmented)) break; | ||||
| 					if(packet->has_flag(PacketFlag::Fragmented)) break; | ||||
| 				} while(packet_count < sequence_length); | ||||
| 
 | ||||
| 				if(packet_count != sequence_length) { | ||||
| @ -381,7 +381,7 @@ bool ProtocolHandler::create_datagram_packets(std::vector<pipes::buffer> &result | ||||
| 	string error = "success"; | ||||
| 
 | ||||
| 	if(packet->type().compressable() && !packet->memory_state.fragment_entry) { | ||||
| 		packet->enableFlag(PacketFlag::Compressed); | ||||
| 		packet->enable_flag(PacketFlag::Compressed); | ||||
| 		if(!this->compression_handler.progressPacketOut(packet.get(), error)) { | ||||
| 			log_error(category::connection, tr("Could not compress outgoing packet.\nThis could cause fatal failed for the client.\nError: {}"), error); | ||||
| 			return false; | ||||
| @ -414,16 +414,16 @@ bool ProtocolHandler::create_datagram_packets(std::vector<pipes::buffer> &result | ||||
| 
 | ||||
| 			for(const auto& frag : siblings) { | ||||
| 				frag->setFragmentedEntry(true); | ||||
| 				frag->enableFlag(PacketFlag::NewProtocol); | ||||
| 				frag->enable_flag(PacketFlag::NewProtocol); | ||||
| 			} | ||||
| 		} | ||||
| 
 | ||||
| 		assert(siblings.size() >= 2); | ||||
| 		siblings.front()->enableFlag(PacketFlag::Fragmented); | ||||
| 		if(packet->hasFlag(PacketFlag::Compressed)) | ||||
| 			siblings.front()->enableFlag(PacketFlag::Compressed); | ||||
| 		siblings.front()->enable_flag(PacketFlag::Fragmented); | ||||
| 		if(packet->has_flag(PacketFlag::Compressed)) | ||||
| 			siblings.front()->enable_flag(PacketFlag::Compressed); | ||||
| 
 | ||||
| 		siblings.back()->enableFlag(PacketFlag::Fragmented); | ||||
| 		siblings.back()->enable_flag(PacketFlag::Fragmented); | ||||
| 
 | ||||
| 		if(packet->getListener()) | ||||
| 			siblings.back()->setListener(std::move(packet->getListener())); //Move the listener to the last :)
 | ||||
| @ -473,7 +473,7 @@ void ProtocolHandler::send_command(const ts::Command &cmd, const std::function<v | ||||
| 			log_trace(category::connection, tr("Time needed for command: {}"), chrono::duration_cast<chrono::milliseconds>(end - begin).count()); | ||||
| 		}); | ||||
| 	} | ||||
| 	packet->enableFlag(PacketFlag::NewProtocol); | ||||
| 	packet->enable_flag(PacketFlag::NewProtocol); | ||||
| 	this->send_packet(packet); | ||||
| } | ||||
| 
 | ||||
|  | ||||
| @ -111,7 +111,7 @@ void ProtocolHandler::handlePacketPing(const std::shared_ptr<ts::protocol::Serve | ||||
| 
 | ||||
| void ProtocolHandler::ping_send_request() { | ||||
| 	auto packet = make_shared<ClientPacket>(PacketTypeInfo::Ping, pipes::buffer_view{}); | ||||
| 	packet->enableFlag(PacketFlag::Unencrypted); | ||||
| 	packet->enable_flag(PacketFlag::Unencrypted); | ||||
| 	this->send_packet(packet); | ||||
| 	assert(packet->memory_state.id_branded); | ||||
| 
 | ||||
|  | ||||
| @ -480,7 +480,7 @@ void ServerConnection::send_voice_data(const void *buffer, size_t buffer_length, | ||||
| 		memcpy(&data_buffer[3], buffer, buffer_length); | ||||
| 
 | ||||
| 	if(head) /* head packet */ | ||||
| 		packet->enableFlag(ts::protocol::PacketFlag::Compressed); | ||||
| 		packet->enable_flag(ts::protocol::PacketFlag::Compressed); | ||||
| 	this->protocol_handler->send_packet(packet); | ||||
| } | ||||
| 
 | ||||
|  | ||||
| @ -296,7 +296,7 @@ void VoiceConnection::process_packet(const std::shared_ptr<ts::protocol::ServerP | ||||
| 		auto packet_id = be2le16(&packet->data()[0]); | ||||
| 		auto client_id = be2le16(&packet->data()[2]); | ||||
| 		auto codec_id = (uint8_t) packet->data()[4]; | ||||
| 		auto flag_head = packet->hasFlag(PacketFlag::Compressed); | ||||
| 		auto flag_head = packet->has_flag(PacketFlag::Compressed); | ||||
| 		//container->voice_data = packet->data().length() > 5 ? packet->data().range(5) : pipes::buffer{};
 | ||||
| 
 | ||||
| 		auto client = this->find_client(client_id); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user