diff --git a/git-teaspeak b/git-teaspeak index 93ac500..ecba83b 160000 --- a/git-teaspeak +++ b/git-teaspeak @@ -1 +1 @@ -Subproject commit 93ac5008175a2925d8031ab04555913fe97e9baf +Subproject commit ecba83b0d985a35e200faba32e1fcfe01fc3ec42 diff --git a/server/src/ConnectionStatistics.h b/server/src/ConnectionStatistics.h index 00ebcbf..c9bd59e 100644 --- a/server/src/ConnectionStatistics.h +++ b/server/src/ConnectionStatistics.h @@ -127,10 +127,6 @@ namespace ts { inline static category::value from_type(uint8_t type){ return lookup_table[type & 0xFU]; } - - inline static category::value from_type(const protocol::PacketTypeInfo& type){ - return from_type(type.type()); - } }; explicit ConnectionStatistics(std::shared_ptr<ConnectionStatistics> /* root */); ~ConnectionStatistics(); diff --git a/server/src/client/ConnectedClientTextCommandHandler.cpp b/server/src/client/ConnectedClientTextCommandHandler.cpp index dd15eb3..8deb298 100644 --- a/server/src/client/ConnectedClientTextCommandHandler.cpp +++ b/server/src/client/ConnectedClientTextCommandHandler.cpp @@ -629,6 +629,7 @@ bool ConnectedClient::handle_text_command( if(!vc) return false; send_message(_this.lock(), "Packet generations:"); + /* for(const auto& type : { protocol::PacketTypeInfo::Command, protocol::PacketTypeInfo::CommandLow, @@ -646,6 +647,7 @@ bool ConnectedClient::handle_text_command( //send_message(_this.lock(), " OUT " + type.name() + " => generation: " + to_string(gen) + " id: " + to_string(id)); //send_message(_this.lock(), " IN " + type.name() + " => generation: " + to_string(genestis[type.type()].generation()) + " id: " + to_string(genestis[type.type()].current_packet_id())); } + */ return true; } else if(TARG(0, "rtt")) { auto vc = dynamic_pointer_cast<VoiceClient>(_this.lock()); diff --git a/server/src/client/voice/CryptSetupHandler.cpp b/server/src/client/voice/CryptSetupHandler.cpp index 63018ef..1b5a087 100644 --- a/server/src/client/voice/CryptSetupHandler.cpp +++ b/server/src/client/voice/CryptSetupHandler.cpp @@ -261,7 +261,7 @@ CryptSetupHandler::CommandResult CryptSetupHandler::handleCommandClientEk(const le2be16(1, buffer); auto pflags = protocol::PacketFlag::NewProtocol; - this->connection->send_packet(protocol::PacketType::ACK, (protocol::PacketFlag::PacketFlag) pflags, buffer, 2); + this->connection->send_packet(protocol::PacketType::ACK, (protocol::PacketFlags) pflags, buffer, 2); //Send the encrypted acknowledge (most the times the second packet; If not we're going into the resend loop) //We cant use the send_packet_acknowledge function since it sends the acknowledge unencrypted } diff --git a/server/src/client/voice/PacketDecoder.h b/server/src/client/voice/PacketDecoder.h index eb193d4..cffa955 100644 --- a/server/src/client/voice/PacketDecoder.h +++ b/server/src/client/voice/PacketDecoder.h @@ -81,7 +81,7 @@ namespace ts::server::server::udp { connection::CryptHandler* crypt_handler_{nullptr}; spin_mutex incoming_generation_estimator_lock{}; - std::array<protocol::generation_estimator, 9> incoming_generation_estimators{}; /* implementation is thread save */ + std::array<protocol::GenerationEstimator, 9> incoming_generation_estimators{}; /* implementation is thread save */ std::recursive_mutex packet_buffer_lock; command_packet_reassembler _command_fragment_buffers; diff --git a/server/src/client/voice/PacketEncoder.cpp b/server/src/client/voice/PacketEncoder.cpp index f0b1acd..6a547ed 100644 --- a/server/src/client/voice/PacketEncoder.cpp +++ b/server/src/client/voice/PacketEncoder.cpp @@ -75,7 +75,7 @@ void PacketEncoder::send_packet(ts::protocol::OutgoingServerPacket *packet) { this->callback_request_write(this->callback_data); } -void PacketEncoder::send_packet(protocol::PacketType type, protocol::PacketFlag::PacketFlags flag, const void *payload, size_t payload_size) { +void PacketEncoder::send_packet(protocol::PacketType type, const protocol::PacketFlags& flag, const void *payload, size_t payload_size) { auto packet = protocol::allocate_outgoing_packet(payload_size); packet->type_and_flags = (uint8_t) type | (uint8_t) flag; @@ -89,7 +89,7 @@ void PacketEncoder::send_packet_acknowledge(uint16_t pid, bool low) { le2be16(pid, buffer); auto pflags = protocol::PacketFlag::Unencrypted | protocol::PacketFlag::NewProtocol; - this->send_packet(low ? protocol::PacketType::ACK_LOW : protocol::PacketType::ACK, (protocol::PacketFlag::PacketFlag) pflags, buffer, 2); + this->send_packet(low ? protocol::PacketType::ACK_LOW : protocol::PacketType::ACK, pflags, buffer, 2); } @@ -271,10 +271,14 @@ bool PacketEncoder::encrypt_outgoing_packet(ts::protocol::OutgoingServerPacket * } } - auto crypt_result = this->crypt_handler_->encrypt((char*) packet->packet_data() + protocol::ServerPacketP::kHeaderOffset, protocol::ServerPacketP::kHeaderLength, - packet->payload, packet->payload_size, - packet->mac, - crypt_key, crypt_nonce, error); + auto crypt_result = this->crypt_handler_->encrypt( + (char*) packet->packet_data() + protocol::ServerPacketParser::kHeaderOffset, + protocol::ServerPacketParser::kHeaderLength, + packet->payload, packet->payload_size, + packet->mac, + crypt_key, crypt_nonce, + error + ); if(!crypt_result) { this->callback_crypt_error(this->callback_data, CryptError::KEY_GENERATION_FAILED, error); return false; diff --git a/server/src/client/voice/PacketEncoder.h b/server/src/client/voice/PacketEncoder.h index 8517430..778caba 100644 --- a/server/src/client/voice/PacketEncoder.h +++ b/server/src/client/voice/PacketEncoder.h @@ -43,7 +43,7 @@ namespace ts::server::server::udp { void reset(); void send_packet(protocol::OutgoingServerPacket* /* packet */); /* will claim ownership */ - void send_packet(protocol::PacketType /* type */, protocol::PacketFlag::PacketFlags /* flags */, const void* /* payload */, size_t /* payload length */); + void send_packet(protocol::PacketType /* type */, const protocol::PacketFlags& /* flags */, const void* /* payload */, size_t /* payload length */); void send_command(const std::string_view& /* build command command */, bool /* command low */, std::unique_ptr<std::function<void(bool)>> /* acknowledge listener */); void send_packet_acknowledge(uint16_t /* packet id */, bool /* acknowledge low */); diff --git a/server/src/client/voice/VoiceClient.cpp b/server/src/client/voice/VoiceClient.cpp index 3b09e21..628cb1f 100644 --- a/server/src/client/voice/VoiceClient.cpp +++ b/server/src/client/voice/VoiceClient.cpp @@ -266,11 +266,11 @@ void VoiceClient::finalDisconnect() { } void VoiceClient::send_voice_packet(const pipes::buffer_view &voice_buffer, const SpeakingClient::VoicePacketFlags &flags) { - PacketFlag::PacketFlags packet_flags{PacketFlag::None}; - packet_flags |= flags.encrypted ? 0U : PacketFlag::Unencrypted; - packet_flags |= flags.head ? PacketFlag::Compressed : 0U; - packet_flags |= flags.fragmented ? PacketFlag::Fragmented : 0U; - packet_flags |= flags.new_protocol ? PacketFlag::NewProtocol : 0U; + protocol::PacketFlags packet_flags{(uint8_t) PacketFlag::None}; + packet_flags |= flags.encrypted ? PacketFlag::None : PacketFlag::Unencrypted; + packet_flags |= flags.head ? PacketFlag::Compressed : PacketFlag::None; + packet_flags |= flags.fragmented ? PacketFlag::Fragmented : PacketFlag::None; + packet_flags |= flags.new_protocol ? PacketFlag::NewProtocol : PacketFlag::None; this->connection->send_packet(PacketType::VOICE, packet_flags, voice_buffer.data_ptr<void>(), voice_buffer.length()); } diff --git a/server/src/client/voice/VoiceClientConnection.cpp b/server/src/client/voice/VoiceClientConnection.cpp index 8a754f7..b907b49 100644 --- a/server/src/client/voice/VoiceClientConnection.cpp +++ b/server/src/client/voice/VoiceClientConnection.cpp @@ -222,7 +222,7 @@ void VoiceClientConnection::reset_remote_address() { memset(&this->remote_address_info_, 0, sizeof(this->remote_address_info_)); } -void VoiceClientConnection::send_packet(protocol::PacketType type, protocol::PacketFlag::PacketFlags flag, const void *payload, size_t payload_size) { +void VoiceClientConnection::send_packet(protocol::PacketType type, const protocol::PacketFlags& flag, const void *payload, size_t payload_size) { this->packet_encoder_.send_packet(type, flag, payload, payload_size); } diff --git a/server/src/client/voice/VoiceClientConnection.h b/server/src/client/voice/VoiceClientConnection.h index 1712d60..9f3c135 100644 --- a/server/src/client/voice/VoiceClientConnection.h +++ b/server/src/client/voice/VoiceClientConnection.h @@ -56,7 +56,7 @@ namespace ts { explicit VoiceClientConnection(server::VoiceClient*); virtual ~VoiceClientConnection(); - void send_packet(protocol::PacketType /* type */, protocol::PacketFlag::PacketFlags /* flags */, const void* /* payload */, size_t /* payload length */); + void send_packet(protocol::PacketType /* type */, const protocol::PacketFlags& /* flags */, const void* /* payload */, size_t /* payload length */); void send_packet(protocol::OutgoingServerPacket* /* packet */); /* method takes ownership of the packet */ void send_command(const std::string_view& /* build command command */, bool /* command low */, std::unique_ptr<std::function<void(bool)>> /* acknowledge listener */); diff --git a/server/src/client/voice/VoiceClientConnectionPacketHandler.cpp b/server/src/client/voice/VoiceClientConnectionPacketHandler.cpp index 3e848e8..dce88a6 100644 --- a/server/src/client/voice/VoiceClientConnectionPacketHandler.cpp +++ b/server/src/client/voice/VoiceClientConnectionPacketHandler.cpp @@ -23,7 +23,7 @@ void VoiceClientConnection::handlePacketPing(const protocol::ClientPacketParser& #endif char buffer[2]; le2be16(packet.packet_id(), buffer); - this->send_packet(PacketType::PONG, PacketFlag::Unencrypted, buffer, 2); + this->send_packet(PacketType::PONG, (uint8_t) PacketFlag::Unencrypted, buffer, 2); } void VoiceClientConnection::handlePacketVoice(const protocol::ClientPacketParser& packet) { diff --git a/shared b/shared index d213c0a..ac48d30 160000 --- a/shared +++ b/shared @@ -1 +1 @@ -Subproject commit d213c0ade0ea0752eec6ce995e661a49a2818a4e +Subproject commit ac48d3069676e7e2f937e7931c6a09ca25a6e594