From c86b9510a5bbbf56930db8e18384b47414ccbc9d Mon Sep 17 00:00:00 2001 From: WolverinDEV Date: Sat, 28 Mar 2020 15:04:55 +0100 Subject: [PATCH] Got rid of a lot of implicit conversations --- native/CMakeLists.txt | 4 +++- native/relink.sh | 2 +- .../src/audio/driver/PortAudioPlayback.cpp | 4 ++-- .../src/audio/driver/PortAudioRecord.cpp | 2 +- .../src/audio/js/AudioConsumer.cpp | 12 ++++++------ .../src/audio/js/AudioFilter.cpp | 6 +++--- .../src/audio/js/AudioOutputStream.cpp | 10 +++++----- .../src/audio/js/AudioPlayer.cpp | 6 +++--- .../src/audio/js/AudioRecorder.cpp | 6 +++--- .../src/audio/sounds/SoundPlayer.cpp | 2 +- .../src/connection/ProtocolHandler.cpp | 2 +- .../src/connection/ProtocolHandler.h | 2 +- .../src/connection/ProtocolHandlerCrypto.cpp | 15 ++++++++------- .../src/connection/ProtocolHandlerPOW.cpp | 10 +++++----- .../src/connection/ProtocolHandlerPackets.cpp | 3 +-- .../src/connection/audio/VoiceClient.cpp | 2 +- .../src/connection/audio/VoiceConnection.cpp | 4 ++-- .../src/connection/ft/FileTransferManager.cpp | 8 ++++---- .../src/connection/ft/FileTransferObject.cpp | 4 ++-- native/serverconnection/src/ring_buffer.cpp | 10 +++++----- native/serverconnection/test/js/main.ts | 18 +++++++++++++----- 21 files changed, 71 insertions(+), 61 deletions(-) diff --git a/native/CMakeLists.txt b/native/CMakeLists.txt index cc20be1..d0678f8 100644 --- a/native/CMakeLists.txt +++ b/native/CMakeLists.txt @@ -4,7 +4,7 @@ project(TeaClient-Natives VERSION 1.0.0) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) -set(CMAKE_VERBOSE_MAKEFILE ON) +# set(CMAKE_VERBOSE_MAKEFILE ON) if (CMAKE_INCLUDE_FILE AND NOT CMAKE_INCLUDE_FILE STREQUAL "") message("Include file ${CMAKE_INCLUDE_FILE}") @@ -111,6 +111,8 @@ if (MSVC) endforeach() #add_compile_options("/MTd") add_compile_options("/EHsc") #We require exception handling + add_compile_options(/wd4275) # needs to have dll-interface to be used by clients of class + add_compile_options(/wd4251) # needs to have dll-interface to be used by clients of class else() #This is a bad thing here! function(resolve_library VARIABLE FALLBACK PATHS) diff --git a/native/relink.sh b/native/relink.sh index 1c90ce8..061ff3d 100755 --- a/native/relink.sh +++ b/native/relink.sh @@ -31,4 +31,4 @@ if [[ ${machine} == "Linux" ]]; then rm teaclient_ppt.node; ln -s ../../ppt/cmake-build-debug/Debug/teaclient_ppt.node fi -#/home/wolverindev/.config/TeaClient/crash_dumps/crash_dump_renderer_04a85069-9d30-48ec-e2fd5e9e-846c5305.dmp \ No newline at end of file +#/home/wolverindev/.config/TeaClient/crash_dumps/crash_dump_renderer_04a85069-9d30-48ec-e2fd5e9e-846c5305.dmp diff --git a/native/serverconnection/src/audio/driver/PortAudioPlayback.cpp b/native/serverconnection/src/audio/driver/PortAudioPlayback.cpp index 22b70b7..493bd41 100644 --- a/native/serverconnection/src/audio/driver/PortAudioPlayback.cpp +++ b/native/serverconnection/src/audio/driver/PortAudioPlayback.cpp @@ -53,7 +53,7 @@ bool PortAudioPlayback::impl_start(std::string &error) { nullptr, ¶meters, (double) kSampleRate, - kSampleRate * kTimeSpan, + (unsigned long) (kSampleRate * kTimeSpan), paClipOff, proxied_write_callback, this); @@ -86,7 +86,7 @@ void PortAudioPlayback::impl_stop() { } size_t PortAudioPlayback::sample_rate() const { - return this->info->defaultSampleRate; + return (size_t) this->info->defaultSampleRate; } void PortAudioPlayback::write_callback(void *output, unsigned long frameCount, diff --git a/native/serverconnection/src/audio/driver/PortAudioRecord.cpp b/native/serverconnection/src/audio/driver/PortAudioRecord.cpp index a522b71..001b8e0 100644 --- a/native/serverconnection/src/audio/driver/PortAudioRecord.cpp +++ b/native/serverconnection/src/audio/driver/PortAudioRecord.cpp @@ -84,7 +84,7 @@ void PortAudioRecord::impl_stop() { } size_t PortAudioRecord::sample_rate() const { - return this->info->defaultSampleRate; + return (size_t) this->info->defaultSampleRate; } void PortAudioRecord::read_callback(const void *input, unsigned long frameCount, diff --git a/native/serverconnection/src/audio/js/AudioConsumer.cpp b/native/serverconnection/src/audio/js/AudioConsumer.cpp index b91b758..05708a1 100644 --- a/native/serverconnection/src/audio/js/AudioConsumer.cpp +++ b/native/serverconnection/src/audio/js/AudioConsumer.cpp @@ -116,9 +116,9 @@ void AudioConsumerWrapper::do_wrap(const v8::Local &obj) { callback_function.As()->Call(Nan::GetCurrentContext(), Nan::Undefined(), 0, nullptr); }); - Nan::Set(this->handle(), Nan::New("frame_size").ToLocalChecked(), Nan::New(this->_handle->frame_size)); - Nan::Set(this->handle(), Nan::New("sample_rate").ToLocalChecked(), Nan::New(this->_handle->sample_rate)); - Nan::Set(this->handle(), Nan::New("channels").ToLocalChecked(), Nan::New(this->_handle->channel_count)); + Nan::Set(this->handle(), Nan::New("frame_size").ToLocalChecked(), Nan::New((uint32_t) this->_handle->frame_size)); + Nan::Set(this->handle(), Nan::New("sample_rate").ToLocalChecked(), Nan::New((uint32_t) this->_handle->sample_rate)); + Nan::Set(this->handle(), Nan::New("channels").ToLocalChecked(), Nan::New((uint32_t) this->_handle->channel_count)); } void AudioConsumerWrapper::unbind() { @@ -237,9 +237,9 @@ NAN_METHOD(AudioConsumerWrapper::_get_filters) { auto handle = ObjectWrap::Unwrap(info.Holder()); auto filters = handle->filters(); - auto result = Nan::New(filters.size()); + auto result = Nan::New((uint32_t) filters.size()); - for(size_t index = 0; index < filters.size(); index++) + for(uint32_t index = 0; index < filters.size(); index++) Nan::Set(result, index, filters[index]->handle()); info.GetReturnValue().Set(result); @@ -296,7 +296,7 @@ NAN_METHOD(AudioConsumerWrapper::_create_filter_threshold) { string error; auto filter = make_shared(consumer->channel_count,consumer->sample_rate,consumer->frame_size); - if(!filter->initialize(error, info[0]->Int32Value(Nan::GetCurrentContext()).FromMaybe(0), 2)) { + if(!filter->initialize(error, (float) info[0]->Int32Value(Nan::GetCurrentContext()).FromMaybe(0), 2)) { Nan::ThrowError(Nan::New("failed to initialize filter (" + error + ")").ToLocalChecked()); return; } diff --git a/native/serverconnection/src/audio/js/AudioFilter.cpp b/native/serverconnection/src/audio/js/AudioFilter.cpp index c456df1..6994ed6 100644 --- a/native/serverconnection/src/audio/js/AudioFilter.cpp +++ b/native/serverconnection/src/audio/js/AudioFilter.cpp @@ -180,7 +180,7 @@ NAN_METHOD(AudioFilterWrapper::_set_threshold) { return; } - filter->set_threshold(info[0]->Int32Value(Nan::GetCurrentContext()).FromMaybe(0)); + filter->set_threshold((float) info[0]->Int32Value(Nan::GetCurrentContext()).FromMaybe(0)); } NAN_METHOD(AudioFilterWrapper::_get_attack_smooth) { @@ -216,7 +216,7 @@ NAN_METHOD(AudioFilterWrapper::_set_attack_smooth) { return; } - filter->attack_smooth(info[0]->NumberValue(Nan::GetCurrentContext()).FromMaybe(0)); + filter->attack_smooth((float) info[0]->NumberValue(Nan::GetCurrentContext()).FromMaybe(0)); } NAN_METHOD(AudioFilterWrapper::_get_release_smooth) { @@ -252,7 +252,7 @@ NAN_METHOD(AudioFilterWrapper::_set_release_smooth) { return; } - filter->release_smooth(info[0]->NumberValue(Nan::GetCurrentContext()).FromMaybe(0)); + filter->release_smooth((float) info[0]->NumberValue(Nan::GetCurrentContext()).FromMaybe(0)); } NAN_METHOD(AudioFilterWrapper::_set_analyze_filter) { diff --git a/native/serverconnection/src/audio/js/AudioOutputStream.cpp b/native/serverconnection/src/audio/js/AudioOutputStream.cpp index 88b49f5..607f3db 100644 --- a/native/serverconnection/src/audio/js/AudioOutputStream.cpp +++ b/native/serverconnection/src/audio/js/AudioOutputStream.cpp @@ -71,8 +71,8 @@ void AudioOutputStreamWrapper::do_wrap(const v8::Local &obj) { return; } - Nan::ForceSet(this->handle(), Nan::New("sample_rate").ToLocalChecked(), Nan::New(handle->sample_rate), v8::ReadOnly); - Nan::ForceSet(this->handle(), Nan::New("channels").ToLocalChecked(), Nan::New(handle->channel_count), v8::ReadOnly); + Nan::DefineOwnProperty(this->handle(), Nan::New("sample_rate").ToLocalChecked(), Nan::New((uint32_t) handle->sample_rate), v8::ReadOnly); + Nan::DefineOwnProperty(this->handle(), Nan::New("channels").ToLocalChecked(), Nan::New((uint32_t) handle->channel_count), v8::ReadOnly); if(this->_own_handle) { this->call_underflow = Nan::async_callback([&]{ @@ -176,7 +176,7 @@ NAN_METHOD(AudioOutputStreamWrapper::_write_data_rated) { info.GetReturnValue().Set((int32_t) write_data(handle, js_buffer.Data(), samples, interleaved)); } else { if(!client->_resampler || client->_resampler->input_rate() != sample_rate) - client->_resampler = make_unique(sample_rate, handle->sample_rate, handle->channel_count); + client->_resampler = make_unique((size_t) sample_rate, handle->sample_rate, handle->channel_count); if(!client->_resampler || !client->_resampler->valid()) { Nan::ThrowError("Resampling failed (invalid resampler)"); @@ -185,7 +185,7 @@ NAN_METHOD(AudioOutputStreamWrapper::_write_data_rated) { //TODO: Use a tmp preallocated buffer here! ssize_t target_samples = client->_resampler->estimated_output_size(samples); - auto buffer = SampleBuffer::allocate(handle->channel_count, max((size_t) samples, (size_t) target_samples)); + auto buffer = SampleBuffer::allocate((uint8_t) handle->channel_count, max((uint16_t) samples, (uint16_t) target_samples)); auto source_buffer = js_buffer.Data(); if(!interleaved) { auto src_buffer = (float*) js_buffer.Data(); @@ -209,7 +209,7 @@ NAN_METHOD(AudioOutputStreamWrapper::_write_data_rated) { } buffer->sample_index = 0; - buffer->sample_size = target_samples; + buffer->sample_size = (uint16_t) target_samples; info.GetReturnValue().Set((int32_t) handle->enqueue_samples(buffer->sample_data, target_samples)); } } diff --git a/native/serverconnection/src/audio/js/AudioPlayer.cpp b/native/serverconnection/src/audio/js/AudioPlayer.cpp index 90db27c..e65880b 100644 --- a/native/serverconnection/src/audio/js/AudioPlayer.cpp +++ b/native/serverconnection/src/audio/js/AudioPlayer.cpp @@ -27,7 +27,7 @@ NAN_METHOD(audio::available_devices) { } auto devices = audio::devices(); - auto result = Nan::New(devices.size()); + auto result = Nan::New((int) devices.size()); for(size_t index = 0; index < devices.size(); index++) { auto device_info = Nan::New(); @@ -43,7 +43,7 @@ NAN_METHOD(audio::available_devices) { Nan::Set(device_info, Nan::LocalString("input_default"), Nan::New(device->is_input_default())); Nan::Set(device_info, Nan::LocalString("output_default"), Nan::New(device->is_output_default())); - Nan::Set(result, index, device_info); + Nan::Set(result, (uint32_t) index, device_info); } info.GetReturnValue().Set(result); @@ -156,5 +156,5 @@ NAN_METHOD(player::set_master_volume) { Nan::ThrowError("invalid arguments"); return; } - global_audio_output->set_volume(info[0]->NumberValue(Nan::GetCurrentContext()).FromMaybe(0)); + global_audio_output->set_volume((float) info[0]->NumberValue(Nan::GetCurrentContext()).FromMaybe(0)); } \ No newline at end of file diff --git a/native/serverconnection/src/audio/js/AudioRecorder.cpp b/native/serverconnection/src/audio/js/AudioRecorder.cpp index 32a8c4b..90a889d 100644 --- a/native/serverconnection/src/audio/js/AudioRecorder.cpp +++ b/native/serverconnection/src/audio/js/AudioRecorder.cpp @@ -226,9 +226,9 @@ NAN_METHOD(AudioRecorderWrapper::_get_consumers) { auto handle = ObjectWrap::Unwrap(info.Holder()); auto consumers = handle->consumers(); - auto result = Nan::New(consumers.size()); + auto result = Nan::New((uint32_t) consumers.size()); - for(size_t index = 0; index < consumers.size(); index++) + for(uint32_t index = 0; index < consumers.size(); index++) Nan::Set(result, index, consumers[index]->handle()); info.GetReturnValue().Set(result); @@ -259,7 +259,7 @@ NAN_METHOD(AudioRecorderWrapper::_set_volume) { return; } - handle->_input->set_volume(info[0]->NumberValue(Nan::GetCurrentContext()).FromMaybe(0)); + handle->_input->set_volume((float) info[0]->NumberValue(Nan::GetCurrentContext()).FromMaybe(0)); } NAN_METHOD(AudioRecorderWrapper::_get_volume) { diff --git a/native/serverconnection/src/audio/sounds/SoundPlayer.cpp b/native/serverconnection/src/audio/sounds/SoundPlayer.cpp index 5f94145..40d12fa 100644 --- a/native/serverconnection/src/audio/sounds/SoundPlayer.cpp +++ b/native/serverconnection/src/audio/sounds/SoundPlayer.cpp @@ -307,5 +307,5 @@ NAN_METHOD(tc::audio::sounds::cancel_playback_js) { return; } - cancel_playback(info[0].As()->Value()); + cancel_playback((sound_playback_id) info[0].As()->Value()); } \ No newline at end of file diff --git a/native/serverconnection/src/connection/ProtocolHandler.cpp b/native/serverconnection/src/connection/ProtocolHandler.cpp index b19c473..2fe370d 100644 --- a/native/serverconnection/src/connection/ProtocolHandler.cpp +++ b/native/serverconnection/src/connection/ProtocolHandler.cpp @@ -184,7 +184,7 @@ void ProtocolHandler::progress_packet(const pipes::buffer_view &buffer) { unique_lock queue_lock(read_queue.buffer_lock); auto result = read_queue.accept_index(packet_id); if(result != 0) { /* packet index is ahead buffer index */ - log_error(category::connection, tr("Failed to verify command packet: {} (Index: {} Current index: {})"), result, packet_id, read_queue.current_index()); + log_error(category::connection, tr("Failed to register command packet ({}) (Index: {} Current index: {})"), result == -1 ? tr("underflow") : tr("overflow"), packet_id, read_queue.current_index()); if(result == -1) { /* underflow */ /* we've already got the packet, but the client dosn't know that so we've to send the acknowledge again */ diff --git a/native/serverconnection/src/connection/ProtocolHandler.h b/native/serverconnection/src/connection/ProtocolHandler.h index 1f9a8c6..f990eba 100644 --- a/native/serverconnection/src/connection/ProtocolHandler.h +++ b/native/serverconnection/src/connection/ProtocolHandler.h @@ -100,7 +100,7 @@ namespace tc { struct { pow_state::value state; - uint32_t client_ts3_build_timestamp = 173265950 /* TS3 */; /* needs to be lower than 173265950 for old stuff, else new protocol */ + uint64_t client_ts3_build_timestamp = 173265950 /* TS3 */; /* needs to be lower than 173265950 for old stuff, else new protocol */ uint8_t client_control_data[4] = {0,0,0,0}; uint8_t server_control_data[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; uint8_t server_data[100]; diff --git a/native/serverconnection/src/connection/ProtocolHandlerCrypto.cpp b/native/serverconnection/src/connection/ProtocolHandlerCrypto.cpp index 0358dec..eab2546 100644 --- a/native/serverconnection/src/connection/ProtocolHandlerCrypto.cpp +++ b/native/serverconnection/src/connection/ProtocolHandlerCrypto.cpp @@ -40,12 +40,13 @@ std::string ProtocolHandler::generate_client_initiv() { if(this->server_type != server_type::TEAMSPEAK) /* if TEAMSPEAK then TS3 has been enforced */ command.enableParm("teaspeak"); /* using "old" encryption system, we expect a teaspeak=1 within the response */ + { size_t buffer_length = 265; char buffer[265]; auto result = ecc_export((unsigned char *) buffer, (unsigned long*) &buffer_length, PK_PUBLIC, &this->crypto.identity); if(result == CRYPT_OK) - command["omega"] = base64::encode(buffer, buffer_length); + command["omega"] = base64::encode(buffer, (unsigned long) buffer_length); else log_error(category::connection, tr("Failed to export identiry ({})"), result); } @@ -70,7 +71,7 @@ void ProtocolHandler::handleCommandInitIVExpend(ts::Command &cmd) { } ecc_key server_key{}; - if(ecc_import((u_char*) omega.data(), omega.length(), &server_key) != CRYPT_OK) { + if(ecc_import((u_char*) omega.data(), (unsigned long) omega.length(), &server_key) != CRYPT_OK) { this->handle->call_connect_result.call(this->handle->errors.register_error(tr("failed to import server key")), true); this->handle->close_connection(); @@ -115,7 +116,7 @@ int __ed_sha512_final(sha512_context* ctx, unsigned char *out) { } int __ed_sha512_update(sha512_context* ctx, const unsigned char *msg, size_t len) { assert(ctx->context); - return sha512_process((hash_state*) ctx->context, msg, len) == CRYPT_OK; + return sha512_process((hash_state*) ctx->context, msg, (unsigned long) len) == CRYPT_OK; } static sha512_functions __ed_sha512_functions { @@ -148,7 +149,7 @@ void ProtocolHandler::handleCommandInitIVExpend2(ts::Command &cmd) { } ecc_key server_key{}; - if(ecc_import((u_char*) omega.data(), omega.length(), &server_key) != CRYPT_OK) { + if(ecc_import((u_char*) omega.data(), (unsigned long) omega.length(), &server_key) != CRYPT_OK) { this->handle->call_connect_result.call(this->handle->errors.register_error(tr("failed to import server key")), true); this->handle->close_connection(); @@ -157,7 +158,7 @@ void ProtocolHandler::handleCommandInitIVExpend2(ts::Command &cmd) { } int result, crypt_result; - if((crypt_result = ecc_verify_hash((u_char*) proof.data(), proof.length(), (u_char*) crypto_hash.data(), crypto_hash.length(), &result, &server_key)) != CRYPT_OK || result != 1) { + if((crypt_result = ecc_verify_hash((u_char*) proof.data(), (unsigned long) proof.length(), (u_char*) crypto_hash.data(), (unsigned long) crypto_hash.length(), &result, &server_key)) != CRYPT_OK || result != 1) { this->handle->call_connect_result.call(this->handle->errors.register_error(tr("failed to verify server integrity")), true); this->handle->close_connection(); return; @@ -188,7 +189,7 @@ void ProtocolHandler::handleCommandInitIVExpend2(ts::Command &cmd) { memset(&prng_state, 0, sizeof(prng_state)); auto proof_data = digest::sha256(string((char*) public_key, 32) + beta); - if(ecc_sign_hash((uint8_t*) proof_data.data(), proof_data.length(), (uint8_t*) sign_buffer, (unsigned long*) &sign_buffer_length, &prng_state, find_prng("sprng"), &this->crypto.identity) != CRYPT_OK) { + if(ecc_sign_hash((uint8_t*) proof_data.data(), (unsigned long) proof_data.length(), (uint8_t*) sign_buffer, (unsigned long*) &sign_buffer_length, &prng_state, find_prng("sprng"), &this->crypto.identity) != CRYPT_OK) { this->handle->call_connect_result.call(this->handle->errors.register_error(tr("failed to generate proof of identity")), true); this->handle->close_connection(); return; @@ -196,7 +197,7 @@ void ProtocolHandler::handleCommandInitIVExpend2(ts::Command &cmd) { Command response("clientek"); response["ek"] = base64::encode((char*) public_key, 32); - response["proof"] = base64::encode(sign_buffer, sign_buffer_length); + response["proof"] = base64::encode(sign_buffer, (unsigned long) sign_buffer_length); /* no need to send this because we're sending the clientinit as the begin packet along with the POW init */ //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, [&](bool success){ diff --git a/native/serverconnection/src/connection/ProtocolHandlerPOW.cpp b/native/serverconnection/src/connection/ProtocolHandlerPOW.cpp index 5330a6a..b384f33 100644 --- a/native/serverconnection/src/connection/ProtocolHandlerPOW.cpp +++ b/native/serverconnection/src/connection/ProtocolHandlerPOW.cpp @@ -70,7 +70,7 @@ void ProtocolHandler::handlePacketInit(const std::shared_ptrhandle->call_connect_result.call(this->handle->errors.register_error(tr("received error: ") + to_string(errc) + " (" + err.message + ")"), true); @@ -83,7 +83,7 @@ void ProtocolHandler::handlePacketInit(const std::shared_ptrpow.state = pow_state::PUZZLE_SET; /* next expected packet state */ uint8_t response_buffer[25]; - le2be32(this->pow.client_ts3_build_timestamp, &response_buffer[0]); + le2be32((uint32_t) this->pow.client_ts3_build_timestamp, &response_buffer[0]); response_buffer[4] = pow_state::PUZZLE_GET; memcpy(&response_buffer[5], this->pow.server_control_data, 16); @@ -124,7 +124,7 @@ void ProtocolHandler::handlePacketInit(const std::shared_ptrpow.client_ts3_build_timestamp, &response_buffer[0]); + le2be32((uint32_t) this->pow.client_ts3_build_timestamp, &response_buffer[0]); response_buffer[4] = pow_state::PUZZLE_SOLVE; memcpy(&response_buffer[5], &data[1], 64 * 2 + 100 + 4); @@ -151,10 +151,10 @@ void ProtocolHandler::pow_send_cookie_get() { this->pow.client_control_data[0] |= 0x01U; } - this->pow.client_ts3_build_timestamp = floor < seconds > ((system_clock::now() - hours{24}).time_since_epoch()).count(); + this->pow.client_ts3_build_timestamp = (uint64_t) floor((system_clock::now() - hours{24}).time_since_epoch()).count(); uint8_t response_buffer[21]; - le2be32(this->pow.client_ts3_build_timestamp, &response_buffer[0]); + le2be32((uint32_t) this->pow.client_ts3_build_timestamp, &response_buffer[0]); response_buffer[4] = pow_state::COOKIE_GET; memset(&response_buffer[5], 0, 4); memcpy(&response_buffer[9], &this->pow.client_control_data, 4); diff --git a/native/serverconnection/src/connection/ProtocolHandlerPackets.cpp b/native/serverconnection/src/connection/ProtocolHandlerPackets.cpp index 64bed4a..83c1cc2 100644 --- a/native/serverconnection/src/connection/ProtocolHandlerPackets.cpp +++ b/native/serverconnection/src/connection/ProtocolHandlerPackets.cpp @@ -25,8 +25,6 @@ void ProtocolHandler::handlePacketAck(const std::shared_ptr &packet) { - cout << "Received command: " << packet->data().string() << endl; - std::unique_ptr command; try { command = make_unique(packet->asCommand()); @@ -37,6 +35,7 @@ void ProtocolHandler::handlePacketCommand(const std::shared_ptrcommand()); if(command->command() == "initivexpand") { this->handleCommandInitIVExpend(*command); diff --git a/native/serverconnection/src/connection/audio/VoiceClient.cpp b/native/serverconnection/src/connection/audio/VoiceClient.cpp index b397594..0d8861f 100644 --- a/native/serverconnection/src/connection/audio/VoiceClient.cpp +++ b/native/serverconnection/src/connection/audio/VoiceClient.cpp @@ -162,7 +162,7 @@ NAN_METHOD(VoiceClientWrap::_set_volume) { return; } - handle->set_volume(info[0]->NumberValue(Nan::GetCurrentContext()).FromMaybe(0)); + handle->set_volume((float) info[0]->NumberValue(Nan::GetCurrentContext()).FromMaybe(0)); } NAN_METHOD(VoiceClientWrap::_abort_replay) { auto client = ObjectWrap::Unwrap(info.Holder()); diff --git a/native/serverconnection/src/connection/audio/VoiceConnection.cpp b/native/serverconnection/src/connection/audio/VoiceConnection.cpp index 47bd55f..7fb1565 100644 --- a/native/serverconnection/src/connection/audio/VoiceConnection.cpp +++ b/native/serverconnection/src/connection/audio/VoiceConnection.cpp @@ -121,8 +121,8 @@ NAN_METHOD(VoiceConnectionWrap::available_clients) { auto client = handle->clients(); - v8::Local result = Nan::New(client.size()); - for(size_t index = 0; index < client.size(); index++) + v8::Local result = Nan::New((int) client.size()); + for(uint32_t index{0}; index < client.size(); index++) Nan::Set(result, index, client[index]->js_handle()); info.GetReturnValue().Set(result); diff --git a/native/serverconnection/src/connection/ft/FileTransferManager.cpp b/native/serverconnection/src/connection/ft/FileTransferManager.cpp index fd075c2..b3e05f5 100644 --- a/native/serverconnection/src/connection/ft/FileTransferManager.cpp +++ b/native/serverconnection/src/connection/ft/FileTransferManager.cpp @@ -116,7 +116,7 @@ bool Transfer::connect() { auto r = wcschr(s, L'\r'); if(r) *r = L'\0'; - this->call_callback_failed(to_string(error) + "/" + std::string{s, s + wcslen(s)}); + this->call_callback_failed(std::to_string(error) + "/" + std::string{s, s + wcslen(s)}); log_trace(category::file_transfer, tr("Failed to connect with code: {} => {}/{}"), result, error, std::string{s, s + wcslen(s)}.c_str()); LocalFree(s); @@ -328,7 +328,7 @@ void Transfer::callback_write(short flags) { readd_write = size > 1; } - auto written = send(this->_socket, buffer.data_ptr(), buffer.length(), MSG_DONTWAIT); + auto written = send(this->_socket, buffer.data_ptr(), (int) buffer.length(), MSG_DONTWAIT); if(written <= 0) { { lock_guard lock(this->queue_lock); @@ -771,8 +771,8 @@ void JSTransfer::callback_progress(uint64_t a, uint64_t b) { return; v8::Local arguments[2]; - arguments[0] = Nan::New(a); - arguments[1] = Nan::New(b); + arguments[0] = Nan::New((uint32_t) a); + arguments[1] = Nan::New((uint32_t) b); callback->Call(Nan::GetCurrentContext(), Nan::Undefined(), 2, arguments); } diff --git a/native/serverconnection/src/connection/ft/FileTransferObject.cpp b/native/serverconnection/src/connection/ft/FileTransferObject.cpp index 8ad9aed..df58e27 100644 --- a/native/serverconnection/src/connection/ft/FileTransferObject.cpp +++ b/native/serverconnection/src/connection/ft/FileTransferObject.cpp @@ -169,14 +169,14 @@ void TransferObjectWrap::do_wrap(v8::Local object) { if(source) { Nan::Set(object, Nan::New("total_size").ToLocalChecked(), - Nan::New(source->byte_length()) + Nan::New((uint32_t) source->byte_length()) ); } if(target) { Nan::Set(object, Nan::New("expected_size").ToLocalChecked(), - Nan::New(target->expected_length()) + Nan::New((uint32_t) target->expected_length()) ); } diff --git a/native/serverconnection/src/ring_buffer.cpp b/native/serverconnection/src/ring_buffer.cpp index ea9e4d3..78256a5 100644 --- a/native/serverconnection/src/ring_buffer.cpp +++ b/native/serverconnection/src/ring_buffer.cpp @@ -66,8 +66,8 @@ namespace tc { } static inline size_t ceil_dbl_to_size_t(double x) { - const double truncation = (size_t)x; - return truncation + (truncation < x); + const auto truncation = (double) x; + return (size_t) (truncation + (truncation < x)); } ring_buffer::ring_buffer(size_t min_capacity) { @@ -84,7 +84,7 @@ namespace tc { this->memory.address = nullptr; #ifdef WIN32 BOOL ok; - HANDLE hMapFile = CreateFileMapping(INVALID_HANDLE_VALUE, nullptr, PAGE_READWRITE, 0, actual_capacity * 2, nullptr); + HANDLE hMapFile = CreateFileMapping(INVALID_HANDLE_VALUE, nullptr, PAGE_READWRITE, 0, (DWORD) (actual_capacity * 2), nullptr); if (!hMapFile) return false; for (;;) { @@ -170,7 +170,7 @@ namespace tc { } void ring_buffer::advance_write_ptr(size_t bytes) { - this->write_offset.fetch_add(bytes); + this->write_offset.fetch_add((long) bytes); assert(this->fill_count() >= 0); } @@ -180,7 +180,7 @@ namespace tc { } void ring_buffer::advance_read_ptr(size_t bytes) { - this->read_offset.fetch_add(bytes); + this->read_offset.fetch_add((long) bytes); assert(this->fill_count() >= 0); } diff --git a/native/serverconnection/test/js/main.ts b/native/serverconnection/test/js/main.ts index e387862..f3715ad 100644 --- a/native/serverconnection/test/js/main.ts +++ b/native/serverconnection/test/js/main.ts @@ -61,8 +61,8 @@ const do_connect = () => { timeout: 5000, remote_port: 9987, //remote_host: "188.40.240.20", /* twerion */ - remote_host: "127.0.0.1", - //remote_host: "ts.teaspeak.de", + //remote_host: "127.0.0.1", + remote_host: "ts.teaspeak.de", //remote_host: "51.68.181.92", //remote_host: "94.130.236.135", //remote_host: "54.36.232.11", /* the beast */ @@ -115,12 +115,20 @@ const do_connect = () => { }; connection.callback_command = (command, arguments1, switches) => { + if(command === "notifyservergrouppermlist") { + console.log("Received perm list"); + return; + } else if(command === "notifyservergroupclientlist") { + console.log("Perm group"); + return; + } console.log("Command: %s: %0", command, arguments1); + if(command === "channellistfinished") { setInterval(() => { - console.log("XXX"); - connection.send_command("channelcreate", [{"channel_name": Math.random() + " :D"}], []); - }, 10); + connection.send_command("servergroupclientlist", [{ sgid: 2 }], []); + connection.send_command("servergrouppermlist", [{ sgid: 2 }], []); + }, 1000); } };