Got rid of a lot of implicit conversations

This commit is contained in:
WolverinDEV 2020-03-28 15:04:55 +01:00
parent 6b3b717cf5
commit c86b9510a5
21 changed files with 71 additions and 61 deletions

View File

@ -4,7 +4,7 @@ project(TeaClient-Natives VERSION 1.0.0)
set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF) 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 "") if (CMAKE_INCLUDE_FILE AND NOT CMAKE_INCLUDE_FILE STREQUAL "")
message("Include file ${CMAKE_INCLUDE_FILE}") message("Include file ${CMAKE_INCLUDE_FILE}")
@ -111,6 +111,8 @@ if (MSVC)
endforeach() endforeach()
#add_compile_options("/MTd") #add_compile_options("/MTd")
add_compile_options("/EHsc") #We require exception handling 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() else()
#This is a bad thing here! #This is a bad thing here!
function(resolve_library VARIABLE FALLBACK PATHS) function(resolve_library VARIABLE FALLBACK PATHS)

View File

@ -31,4 +31,4 @@ if [[ ${machine} == "Linux" ]]; then
rm teaclient_ppt.node; ln -s ../../ppt/cmake-build-debug/Debug/teaclient_ppt.node rm teaclient_ppt.node; ln -s ../../ppt/cmake-build-debug/Debug/teaclient_ppt.node
fi fi
#/home/wolverindev/.config/TeaClient/crash_dumps/crash_dump_renderer_04a85069-9d30-48ec-e2fd5e9e-846c5305.dmp #/home/wolverindev/.config/TeaClient/crash_dumps/crash_dump_renderer_04a85069-9d30-48ec-e2fd5e9e-846c5305.dmp

View File

@ -53,7 +53,7 @@ bool PortAudioPlayback::impl_start(std::string &error) {
nullptr, nullptr,
&parameters, &parameters,
(double) kSampleRate, (double) kSampleRate,
kSampleRate * kTimeSpan, (unsigned long) (kSampleRate * kTimeSpan),
paClipOff, paClipOff,
proxied_write_callback, proxied_write_callback,
this); this);
@ -86,7 +86,7 @@ void PortAudioPlayback::impl_stop() {
} }
size_t PortAudioPlayback::sample_rate() const { 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, void PortAudioPlayback::write_callback(void *output, unsigned long frameCount,

View File

@ -84,7 +84,7 @@ void PortAudioRecord::impl_stop() {
} }
size_t PortAudioRecord::sample_rate() const { 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, void PortAudioRecord::read_callback(const void *input, unsigned long frameCount,

View File

@ -116,9 +116,9 @@ void AudioConsumerWrapper::do_wrap(const v8::Local<v8::Object> &obj) {
callback_function.As<v8::Function>()->Call(Nan::GetCurrentContext(), Nan::Undefined(), 0, nullptr); callback_function.As<v8::Function>()->Call(Nan::GetCurrentContext(), Nan::Undefined(), 0, nullptr);
}); });
Nan::Set(this->handle(), Nan::New<v8::String>("frame_size").ToLocalChecked(), Nan::New<v8::Number>(this->_handle->frame_size)); Nan::Set(this->handle(), Nan::New<v8::String>("frame_size").ToLocalChecked(), Nan::New<v8::Number>((uint32_t) this->_handle->frame_size));
Nan::Set(this->handle(), Nan::New<v8::String>("sample_rate").ToLocalChecked(), Nan::New<v8::Number>(this->_handle->sample_rate)); Nan::Set(this->handle(), Nan::New<v8::String>("sample_rate").ToLocalChecked(), Nan::New<v8::Number>((uint32_t) this->_handle->sample_rate));
Nan::Set(this->handle(), Nan::New<v8::String>("channels").ToLocalChecked(), Nan::New<v8::Number>(this->_handle->channel_count)); Nan::Set(this->handle(), Nan::New<v8::String>("channels").ToLocalChecked(), Nan::New<v8::Number>((uint32_t) this->_handle->channel_count));
} }
void AudioConsumerWrapper::unbind() { void AudioConsumerWrapper::unbind() {
@ -237,9 +237,9 @@ NAN_METHOD(AudioConsumerWrapper::_get_filters) {
auto handle = ObjectWrap::Unwrap<AudioConsumerWrapper>(info.Holder()); auto handle = ObjectWrap::Unwrap<AudioConsumerWrapper>(info.Holder());
auto filters = handle->filters(); auto filters = handle->filters();
auto result = Nan::New<v8::Array>(filters.size()); auto result = Nan::New<v8::Array>((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()); Nan::Set(result, index, filters[index]->handle());
info.GetReturnValue().Set(result); info.GetReturnValue().Set(result);
@ -296,7 +296,7 @@ NAN_METHOD(AudioConsumerWrapper::_create_filter_threshold) {
string error; string error;
auto filter = make_shared<filter::ThresholdFilter>(consumer->channel_count,consumer->sample_rate,consumer->frame_size); auto filter = make_shared<filter::ThresholdFilter>(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<v8::String>("failed to initialize filter (" + error + ")").ToLocalChecked()); Nan::ThrowError(Nan::New<v8::String>("failed to initialize filter (" + error + ")").ToLocalChecked());
return; return;
} }

View File

@ -180,7 +180,7 @@ NAN_METHOD(AudioFilterWrapper::_set_threshold) {
return; 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) { NAN_METHOD(AudioFilterWrapper::_get_attack_smooth) {
@ -216,7 +216,7 @@ NAN_METHOD(AudioFilterWrapper::_set_attack_smooth) {
return; 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) { NAN_METHOD(AudioFilterWrapper::_get_release_smooth) {
@ -252,7 +252,7 @@ NAN_METHOD(AudioFilterWrapper::_set_release_smooth) {
return; 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) { NAN_METHOD(AudioFilterWrapper::_set_analyze_filter) {

View File

@ -71,8 +71,8 @@ void AudioOutputStreamWrapper::do_wrap(const v8::Local<v8::Object> &obj) {
return; return;
} }
Nan::ForceSet(this->handle(), Nan::New<v8::String>("sample_rate").ToLocalChecked(), Nan::New<v8::Number>(handle->sample_rate), v8::ReadOnly); Nan::DefineOwnProperty(this->handle(), Nan::New<v8::String>("sample_rate").ToLocalChecked(), Nan::New<v8::Number>((uint32_t) handle->sample_rate), v8::ReadOnly);
Nan::ForceSet(this->handle(), Nan::New<v8::String>("channels").ToLocalChecked(), Nan::New<v8::Number>(handle->channel_count), v8::ReadOnly); Nan::DefineOwnProperty(this->handle(), Nan::New<v8::String>("channels").ToLocalChecked(), Nan::New<v8::Number>((uint32_t) handle->channel_count), v8::ReadOnly);
if(this->_own_handle) { if(this->_own_handle) {
this->call_underflow = Nan::async_callback([&]{ 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)); info.GetReturnValue().Set((int32_t) write_data(handle, js_buffer.Data(), samples, interleaved));
} else { } else {
if(!client->_resampler || client->_resampler->input_rate() != sample_rate) if(!client->_resampler || client->_resampler->input_rate() != sample_rate)
client->_resampler = make_unique<AudioResampler>(sample_rate, handle->sample_rate, handle->channel_count); client->_resampler = make_unique<AudioResampler>((size_t) sample_rate, handle->sample_rate, handle->channel_count);
if(!client->_resampler || !client->_resampler->valid()) { if(!client->_resampler || !client->_resampler->valid()) {
Nan::ThrowError("Resampling failed (invalid resampler)"); Nan::ThrowError("Resampling failed (invalid resampler)");
@ -185,7 +185,7 @@ NAN_METHOD(AudioOutputStreamWrapper::_write_data_rated) {
//TODO: Use a tmp preallocated buffer here! //TODO: Use a tmp preallocated buffer here!
ssize_t target_samples = client->_resampler->estimated_output_size(samples); 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(); auto source_buffer = js_buffer.Data();
if(!interleaved) { if(!interleaved) {
auto src_buffer = (float*) js_buffer.Data(); auto src_buffer = (float*) js_buffer.Data();
@ -209,7 +209,7 @@ NAN_METHOD(AudioOutputStreamWrapper::_write_data_rated) {
} }
buffer->sample_index = 0; 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)); info.GetReturnValue().Set((int32_t) handle->enqueue_samples(buffer->sample_data, target_samples));
} }
} }

View File

@ -27,7 +27,7 @@ NAN_METHOD(audio::available_devices) {
} }
auto devices = audio::devices(); auto devices = audio::devices();
auto result = Nan::New<v8::Array>(devices.size()); auto result = Nan::New<v8::Array>((int) devices.size());
for(size_t index = 0; index < devices.size(); index++) { for(size_t index = 0; index < devices.size(); index++) {
auto device_info = Nan::New<v8::Object>(); auto device_info = Nan::New<v8::Object>();
@ -43,7 +43,7 @@ NAN_METHOD(audio::available_devices) {
Nan::Set(device_info, Nan::LocalString("input_default"), Nan::New<v8::Boolean>(device->is_input_default())); Nan::Set(device_info, Nan::LocalString("input_default"), Nan::New<v8::Boolean>(device->is_input_default()));
Nan::Set(device_info, Nan::LocalString("output_default"), Nan::New<v8::Boolean>(device->is_output_default())); Nan::Set(device_info, Nan::LocalString("output_default"), Nan::New<v8::Boolean>(device->is_output_default()));
Nan::Set(result, index, device_info); Nan::Set(result, (uint32_t) index, device_info);
} }
info.GetReturnValue().Set(result); info.GetReturnValue().Set(result);
@ -156,5 +156,5 @@ NAN_METHOD(player::set_master_volume) {
Nan::ThrowError("invalid arguments"); Nan::ThrowError("invalid arguments");
return; 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));
} }

View File

@ -226,9 +226,9 @@ NAN_METHOD(AudioRecorderWrapper::_get_consumers) {
auto handle = ObjectWrap::Unwrap<AudioRecorderWrapper>(info.Holder()); auto handle = ObjectWrap::Unwrap<AudioRecorderWrapper>(info.Holder());
auto consumers = handle->consumers(); auto consumers = handle->consumers();
auto result = Nan::New<v8::Array>(consumers.size()); auto result = Nan::New<v8::Array>((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()); Nan::Set(result, index, consumers[index]->handle());
info.GetReturnValue().Set(result); info.GetReturnValue().Set(result);
@ -259,7 +259,7 @@ NAN_METHOD(AudioRecorderWrapper::_set_volume) {
return; 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) { NAN_METHOD(AudioRecorderWrapper::_get_volume) {

View File

@ -307,5 +307,5 @@ NAN_METHOD(tc::audio::sounds::cancel_playback_js) {
return; return;
} }
cancel_playback(info[0].As<v8::Number>()->Value()); cancel_playback((sound_playback_id) info[0].As<v8::Number>()->Value());
} }

View File

@ -184,7 +184,7 @@ void ProtocolHandler::progress_packet(const pipes::buffer_view &buffer) {
unique_lock queue_lock(read_queue.buffer_lock); unique_lock queue_lock(read_queue.buffer_lock);
auto result = read_queue.accept_index(packet_id); auto result = read_queue.accept_index(packet_id);
if(result != 0) { /* packet index is ahead buffer index */ 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 */ 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 */ /* we've already got the packet, but the client dosn't know that so we've to send the acknowledge again */

View File

@ -100,7 +100,7 @@ namespace tc {
struct { struct {
pow_state::value state; 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 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_control_data[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
uint8_t server_data[100]; uint8_t server_data[100];

View File

@ -40,12 +40,13 @@ std::string ProtocolHandler::generate_client_initiv() {
if(this->server_type != server_type::TEAMSPEAK) /* if TEAMSPEAK then TS3 has been enforced */ 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 */ command.enableParm("teaspeak"); /* using "old" encryption system, we expect a teaspeak=1 within the response */
{ {
size_t buffer_length = 265; size_t buffer_length = 265;
char buffer[265]; char buffer[265];
auto result = ecc_export((unsigned char *) buffer, (unsigned long*) &buffer_length, PK_PUBLIC, &this->crypto.identity); auto result = ecc_export((unsigned char *) buffer, (unsigned long*) &buffer_length, PK_PUBLIC, &this->crypto.identity);
if(result == CRYPT_OK) if(result == CRYPT_OK)
command["omega"] = base64::encode(buffer, buffer_length); command["omega"] = base64::encode(buffer, (unsigned long) buffer_length);
else else
log_error(category::connection, tr("Failed to export identiry ({})"), result); log_error(category::connection, tr("Failed to export identiry ({})"), result);
} }
@ -70,7 +71,7 @@ void ProtocolHandler::handleCommandInitIVExpend(ts::Command &cmd) {
} }
ecc_key server_key{}; 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->call_connect_result.call(this->handle->errors.register_error(tr("failed to import server key")), true);
this->handle->close_connection(); 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) { int __ed_sha512_update(sha512_context* ctx, const unsigned char *msg, size_t len) {
assert(ctx->context); 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 { static sha512_functions __ed_sha512_functions {
@ -148,7 +149,7 @@ void ProtocolHandler::handleCommandInitIVExpend2(ts::Command &cmd) {
} }
ecc_key server_key{}; 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->call_connect_result.call(this->handle->errors.register_error(tr("failed to import server key")), true);
this->handle->close_connection(); this->handle->close_connection();
@ -157,7 +158,7 @@ void ProtocolHandler::handleCommandInitIVExpend2(ts::Command &cmd) {
} }
int result, crypt_result; 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->call_connect_result.call(this->handle->errors.register_error(tr("failed to verify server integrity")), true);
this->handle->close_connection(); this->handle->close_connection();
return; return;
@ -188,7 +189,7 @@ void ProtocolHandler::handleCommandInitIVExpend2(ts::Command &cmd) {
memset(&prng_state, 0, sizeof(prng_state)); memset(&prng_state, 0, sizeof(prng_state));
auto proof_data = digest::sha256(string((char*) public_key, 32) + beta); 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->call_connect_result.call(this->handle->errors.register_error(tr("failed to generate proof of identity")), true);
this->handle->close_connection(); this->handle->close_connection();
return; return;
@ -196,7 +197,7 @@ void ProtocolHandler::handleCommandInitIVExpend2(ts::Command &cmd) {
Command response("clientek"); Command response("clientek");
response["ek"] = base64::encode((char*) public_key, 32); 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 */ /* 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->_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){ this->send_command(response, [&](bool success){

View File

@ -70,7 +70,7 @@ void ProtocolHandler::handlePacketInit(const std::shared_ptr<ts::protocol::Serve
//TODO test client data reserved bytes //TODO test client data reserved bytes
} else { } else {
auto errc = ntohl(*(uint32_t*) &data[1]); auto errc = ntohl(*(uint32_t*) &data[1]);
auto err = ts::findError(errc); auto err = ts::findError((uint16_t) errc);
log_error(category::connection, tr("[POW] Received error code: {:x} ({})"), errc, err.message); log_error(category::connection, tr("[POW] Received error code: {:x} ({})"), errc, err.message);
this->handle->call_connect_result.call(this->handle->errors.register_error(tr("received error: ") + to_string(errc) + " (" + err.message + ")"), true); this->handle->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_ptr<ts::protocol::Serve
this->pow.state = pow_state::PUZZLE_SET; /* next expected packet state */ this->pow.state = pow_state::PUZZLE_SET; /* next expected packet state */
uint8_t response_buffer[25]; 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; response_buffer[4] = pow_state::PUZZLE_GET;
memcpy(&response_buffer[5], this->pow.server_control_data, 16); memcpy(&response_buffer[5], this->pow.server_control_data, 16);
@ -124,7 +124,7 @@ void ProtocolHandler::handlePacketInit(const std::shared_ptr<ts::protocol::Serve
size_t response_buffer_length = 301 + command.size(); size_t response_buffer_length = 301 + command.size();
auto response_buffer = buffer::allocate_buffer(response_buffer_length); auto response_buffer = buffer::allocate_buffer(response_buffer_length);
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_SOLVE; response_buffer[4] = pow_state::PUZZLE_SOLVE;
memcpy(&response_buffer[5], &data[1], 64 * 2 + 100 + 4); 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_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<seconds>((system_clock::now() - hours{24}).time_since_epoch()).count();
uint8_t response_buffer[21]; 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; response_buffer[4] = pow_state::COOKIE_GET;
memset(&response_buffer[5], 0, 4); memset(&response_buffer[5], 0, 4);
memcpy(&response_buffer[9], &this->pow.client_control_data, 4); memcpy(&response_buffer[9], &this->pow.client_control_data, 4);

View File

@ -25,8 +25,6 @@ void ProtocolHandler::handlePacketAck(const std::shared_ptr<ts::protocol::Server
} }
void ProtocolHandler::handlePacketCommand(const std::shared_ptr<ts::protocol::ServerPacket> &packet) { void ProtocolHandler::handlePacketCommand(const std::shared_ptr<ts::protocol::ServerPacket> &packet) {
cout << "Received command: " << packet->data().string() << endl;
std::unique_ptr<Command> command; std::unique_ptr<Command> command;
try { try {
command = make_unique<Command>(packet->asCommand()); command = make_unique<Command>(packet->asCommand());
@ -37,6 +35,7 @@ void ProtocolHandler::handlePacketCommand(const std::shared_ptr<ts::protocol::Se
log_error(category::connection, tr("Failed to parse command (exception): {}"), ex.what()); log_error(category::connection, tr("Failed to parse command (exception): {}"), ex.what());
return; return;
} }
log_trace(category::connection, tr("Handing command {}"), command->command());
if(command->command() == "initivexpand") { if(command->command() == "initivexpand") {
this->handleCommandInitIVExpend(*command); this->handleCommandInitIVExpend(*command);

View File

@ -162,7 +162,7 @@ NAN_METHOD(VoiceClientWrap::_set_volume) {
return; 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) { NAN_METHOD(VoiceClientWrap::_abort_replay) {
auto client = ObjectWrap::Unwrap<VoiceClientWrap>(info.Holder()); auto client = ObjectWrap::Unwrap<VoiceClientWrap>(info.Holder());

View File

@ -121,8 +121,8 @@ NAN_METHOD(VoiceConnectionWrap::available_clients) {
auto client = handle->clients(); auto client = handle->clients();
v8::Local<v8::Array> result = Nan::New<v8::Array>(client.size()); v8::Local<v8::Array> result = Nan::New<v8::Array>((int) client.size());
for(size_t index = 0; index < client.size(); index++) for(uint32_t index{0}; index < client.size(); index++)
Nan::Set(result, index, client[index]->js_handle()); Nan::Set(result, index, client[index]->js_handle());
info.GetReturnValue().Set(result); info.GetReturnValue().Set(result);

View File

@ -116,7 +116,7 @@ bool Transfer::connect() {
auto r = wcschr(s, L'\r'); auto r = wcschr(s, L'\r');
if(r) *r = L'\0'; 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()); log_trace(category::file_transfer, tr("Failed to connect with code: {} => {}/{}"), result, error, std::string{s, s + wcslen(s)}.c_str());
LocalFree(s); LocalFree(s);
@ -328,7 +328,7 @@ void Transfer::callback_write(short flags) {
readd_write = size > 1; readd_write = size > 1;
} }
auto written = send(this->_socket, buffer.data_ptr<char>(), buffer.length(), MSG_DONTWAIT); auto written = send(this->_socket, buffer.data_ptr<char>(), (int) buffer.length(), MSG_DONTWAIT);
if(written <= 0) { if(written <= 0) {
{ {
lock_guard lock(this->queue_lock); lock_guard lock(this->queue_lock);
@ -771,8 +771,8 @@ void JSTransfer::callback_progress(uint64_t a, uint64_t b) {
return; return;
v8::Local<v8::Value> arguments[2]; v8::Local<v8::Value> arguments[2];
arguments[0] = Nan::New<v8::Number>(a); arguments[0] = Nan::New<v8::Number>((uint32_t) a);
arguments[1] = Nan::New<v8::Number>(b); arguments[1] = Nan::New<v8::Number>((uint32_t) b);
callback->Call(Nan::GetCurrentContext(), Nan::Undefined(), 2, arguments); callback->Call(Nan::GetCurrentContext(), Nan::Undefined(), 2, arguments);
} }

View File

@ -169,14 +169,14 @@ void TransferObjectWrap::do_wrap(v8::Local<v8::Object> object) {
if(source) { if(source) {
Nan::Set(object, Nan::Set(object,
Nan::New<v8::String>("total_size").ToLocalChecked(), Nan::New<v8::String>("total_size").ToLocalChecked(),
Nan::New<v8::Number>(source->byte_length()) Nan::New<v8::Number>((uint32_t) source->byte_length())
); );
} }
if(target) { if(target) {
Nan::Set(object, Nan::Set(object,
Nan::New<v8::String>("expected_size").ToLocalChecked(), Nan::New<v8::String>("expected_size").ToLocalChecked(),
Nan::New<v8::Number>(target->expected_length()) Nan::New<v8::Number>((uint32_t) target->expected_length())
); );
} }

View File

@ -66,8 +66,8 @@ namespace tc {
} }
static inline size_t ceil_dbl_to_size_t(double x) { static inline size_t ceil_dbl_to_size_t(double x) {
const double truncation = (size_t)x; const auto truncation = (double) x;
return truncation + (truncation < x); return (size_t) (truncation + (truncation < x));
} }
ring_buffer::ring_buffer(size_t min_capacity) { ring_buffer::ring_buffer(size_t min_capacity) {
@ -84,7 +84,7 @@ namespace tc {
this->memory.address = nullptr; this->memory.address = nullptr;
#ifdef WIN32 #ifdef WIN32
BOOL ok; 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; if (!hMapFile) return false;
for (;;) { for (;;) {
@ -170,7 +170,7 @@ namespace tc {
} }
void ring_buffer::advance_write_ptr(size_t bytes) { 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); assert(this->fill_count() >= 0);
} }
@ -180,7 +180,7 @@ namespace tc {
} }
void ring_buffer::advance_read_ptr(size_t bytes) { 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); assert(this->fill_count() >= 0);
} }

View File

@ -61,8 +61,8 @@ const do_connect = () => {
timeout: 5000, timeout: 5000,
remote_port: 9987, remote_port: 9987,
//remote_host: "188.40.240.20", /* twerion */ //remote_host: "188.40.240.20", /* twerion */
remote_host: "127.0.0.1", //remote_host: "127.0.0.1",
//remote_host: "ts.teaspeak.de", remote_host: "ts.teaspeak.de",
//remote_host: "51.68.181.92", //remote_host: "51.68.181.92",
//remote_host: "94.130.236.135", //remote_host: "94.130.236.135",
//remote_host: "54.36.232.11", /* the beast */ //remote_host: "54.36.232.11", /* the beast */
@ -115,12 +115,20 @@ const do_connect = () => {
}; };
connection.callback_command = (command, arguments1, switches) => { 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); console.log("Command: %s: %0", command, arguments1);
if(command === "channellistfinished") { if(command === "channellistfinished") {
setInterval(() => { setInterval(() => {
console.log("XXX"); connection.send_command("servergroupclientlist", [{ sgid: 2 }], []);
connection.send_command("channelcreate", [{"channel_name": Math.random() + " :D"}], []); connection.send_command("servergrouppermlist", [{ sgid: 2 }], []);
}, 10); }, 1000);
} }
}; };