From 37e3cfc30e0e1ccda850c66f11b742d7df81ffd0 Mon Sep 17 00:00:00 2001 From: WolverinDEV Date: Sat, 13 Feb 2021 23:55:14 +0100 Subject: [PATCH] Fixed TS3 client --- native/serverconnection/src/bindings.cpp | 4 ++-- .../serverconnection/src/connection/ProtocolHandler.cpp | 9 ++++++--- .../src/connection/ProtocolHandlerCrypto.cpp | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/native/serverconnection/src/bindings.cpp b/native/serverconnection/src/bindings.cpp index 63fb8af..b17217a 100644 --- a/native/serverconnection/src/bindings.cpp +++ b/native/serverconnection/src/bindings.cpp @@ -70,8 +70,8 @@ tc::audio::AudioOutput* global_audio_output; Nan::Set(object, (uint32_t) value, Nan::New(key).ToLocalChecked()); NAN_MODULE_INIT(init) { - //logger::initialize_node(); - logger::initialize_raw(); + logger::initialize_node(); + //logger::initialize_raw(); #ifndef WIN32 logger::info(category::general, tr("Hello World from C. PPID: {}, PID: {}"), getppid(), getpid()); diff --git a/native/serverconnection/src/connection/ProtocolHandler.cpp b/native/serverconnection/src/connection/ProtocolHandler.cpp index f642870..0ae19fc 100644 --- a/native/serverconnection/src/connection/ProtocolHandler.cpp +++ b/native/serverconnection/src/connection/ProtocolHandler.cpp @@ -18,7 +18,6 @@ using namespace ts::protocol; using namespace ts; ProtocolHandler::ProtocolHandler(ServerConnection* handle) : handle{handle}, packet_decoder{&this->crypt_handler, false} { - this->packet_decoder.callback_argument = this; this->packet_decoder.callback_decoded_packet = ProtocolHandler::callback_packet_decoded; this->packet_decoder.callback_decoded_command = ProtocolHandler::callback_command_decoded; @@ -334,7 +333,7 @@ void ProtocolHandler::send_packet(ts::protocol::OutgoingClientPacket *packet, bo } /* Since we assume that the packets gets written instantly we're setting the next ptr to null */ - if((packet->type_and_flags_ & PacketFlag::Unencrypted) || !this->crypt_setupped) { + if(packet->type_and_flags_ & PacketFlag::Unencrypted) { this->crypt_handler.write_default_mac(packet->mac); } else { ts::connection::CryptHandler::key_t crypt_key{}; @@ -516,7 +515,11 @@ void ProtocolHandler::send_acknowledge(uint16_t packet_id, bool low) { auto packet = protocol::allocate_outgoing_client_packet(2); packet->type_and_flags_ = (uint8_t) (low ? protocol::PacketType::ACK_LOW : protocol::PacketType::ACK) | - (uint8_t) (protocol::PacketFlag::Unencrypted | protocol::PacketFlag::NewProtocol); + (uint8_t) (protocol::PacketFlag::NewProtocol); + + if(!this->crypt_setupped) { + packet->type_and_flags_ |= protocol::PacketFlag::Unencrypted; + } le2be16(packet_id, packet->payload); this->send_packet(packet, false); diff --git a/native/serverconnection/src/connection/ProtocolHandlerCrypto.cpp b/native/serverconnection/src/connection/ProtocolHandlerCrypto.cpp index bb2ed33..8e65b13 100644 --- a/native/serverconnection/src/connection/ProtocolHandlerCrypto.cpp +++ b/native/serverconnection/src/connection/ProtocolHandlerCrypto.cpp @@ -204,8 +204,8 @@ void ProtocolHandler::handleCommandInitIVExpend2(ts::Command &cmd) { //this->_packet_id_manager.nextPacketId(PacketTypeInfo::Command); /* skip the first because we've send our first command within the low level handshake packets */ this->send_command(response, false, std::make_unique>([&](bool success){ if(success) { - /* trigger connected; because the connection has been established on protocol layer */ this->crypt_setupped = true; + /* trigger connected; because the connection has been established on protocol layer */ this->handle->call_connect_result.call(0, true); this->connection_state = connection_state::CONNECTING; }