Some smaller changes and code cleanups
This commit is contained in:
parent
a608b52269
commit
54e0571132
@ -1 +1 @@
|
||||
Subproject commit 93ac5008175a2925d8031ab04555913fe97e9baf
|
||||
Subproject commit ecba83b0d985a35e200faba32e1fcfe01fc3ec42
|
@ -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();
|
||||
|
@ -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());
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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 */);
|
||||
|
@ -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());
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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 */);
|
||||
|
||||
|
@ -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) {
|
||||
|
2
shared
2
shared
@ -1 +1 @@
|
||||
Subproject commit d213c0ade0ea0752eec6ce995e661a49a2818a4e
|
||||
Subproject commit ac48d3069676e7e2f937e7931c6a09ca25a6e594
|
Loading…
x
Reference in New Issue
Block a user