diff --git a/installer/tsconfig_windows.json b/installer/tsconfig_windows.json index 87dbbc8..4001168 100644 --- a/installer/tsconfig_windows.json +++ b/installer/tsconfig_windows.json @@ -9,6 +9,6 @@ "./deploy/", "build.ts", "package.ts", - "package_linux.ts" + "package_windows.ts" ] -} \ No newline at end of file +} diff --git a/native/serverconnection/src/bindings.cpp b/native/serverconnection/src/bindings.cpp index c82745e..bf4167b 100644 --- a/native/serverconnection/src/bindings.cpp +++ b/native/serverconnection/src/bindings.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include "logger.h" #include "NanException.h" @@ -61,7 +62,6 @@ void testTomMath(){ mp_clear_multi(&x, &n, &exp, &r, nullptr); } - tc::audio::AudioOutput* global_audio_output; #define ENUM_SET(object, key, value) \ Nan::DefineOwnProperty(object, Nan::New(key).ToLocalChecked(), Nan::New(value), v8::DontDelete); \ @@ -71,6 +71,30 @@ NAN_MODULE_INIT(init) { logger::initialize_node(); logger::info(category::general, "Hello World from C"); + /* + { + auto data = (uint8_t*) "Hello World"; + auto hash_result = digest::sha1((const char*) data, 11); + if(hash_result.length() != 20) + Nan::ThrowError("digest::sha1 test failed"); + log_error(category::connection, tr("Hash result: {}"), hash_result.length()); + } + */ + { + auto data = (uint8_t*) "Hello World"; + auto hash_result = digest::sha1(std::string("Hello World")); + if(hash_result.length() != 20) + Nan::ThrowError("digest::sha1 test failed"); + } + { + auto data = (uint8_t*) "Hello World"; + + uint8_t result[SHA_DIGEST_LENGTH]; + digest::tomcrypt::sha1((char*) data, 11, result); + auto hash_result = std::string((const char*) result, SHA_DIGEST_LENGTH); + log_error(category::connection, tr("Hash result: {}"), hash_result.length()); + } + string error; //TODO here //PaJack_SetClientName("TeaClient"); diff --git a/native/serverconnection/src/connection/ProtocolHandler.cpp b/native/serverconnection/src/connection/ProtocolHandler.cpp index e05272b..eadebb2 100644 --- a/native/serverconnection/src/connection/ProtocolHandler.cpp +++ b/native/serverconnection/src/connection/ProtocolHandler.cpp @@ -444,6 +444,7 @@ bool ProtocolHandler::create_datagram_packets(std::vector &result } else { packet->applyPacketId(this->_packet_id_manager); } + log_trace(category::connection, tr("Packet {} got packet id {}"), packet->type().name(), packet->packetId()); } if(!this->crypt_handler.progressPacketOut(packet.get(), error, false)) { log_error(category::connection, tr("Failed to encrypt packet: {}"), error); diff --git a/native/serverconnection/src/connection/ProtocolHandlerCrypto.cpp b/native/serverconnection/src/connection/ProtocolHandlerCrypto.cpp index 4ed22b6..7cea312 100644 --- a/native/serverconnection/src/connection/ProtocolHandlerCrypto.cpp +++ b/native/serverconnection/src/connection/ProtocolHandlerCrypto.cpp @@ -47,7 +47,7 @@ std::string ProtocolHandler::generate_client_initiv() { if(result == CRYPT_OK) command["omega"] = base64::encode(buffer, buffer_length); else - cout << "Failed to export identity (" << result << ")" << endl; + log_error(category::connection, tr("Failed to export identiry ({})"), result); } this->crypto.initiv_command = command.build(true); @@ -80,7 +80,7 @@ void ProtocolHandler::handleCommandInitIVExpend(ts::Command &cmd) { string error; if(!this->crypt_handler.setupSharedSecret(alpha, beta, &server_key, &this->crypto.identity, error)) { - this->handle->call_connect_result.call(this->handle->errors.register_error(tr("failed to setup encryption (I)")), true); + this->handle->call_connect_result.call(this->handle->errors.register_error(tr("failed to setup encryption")), true); this->handle->close_connection(); log_error(category::connection, tr("Failed to setup crypto ({})"), error); @@ -135,7 +135,7 @@ void ProtocolHandler::handleCommandInitIVExpend2(ts::Command &cmd) { auto proof = base64::decode(cmd["proof"]); auto crypto_chain_data = base64::decode(cmd["l"]); - auto crypto_root = cmd[0].has("root") ? base64::decode(cmd["root"]) : std::string((char*) license::teamspeak::public_root, 32); + auto crypto_root = cmd[0].has("root") ? base64::decode(cmd["root"]) : string((char*) license::teamspeak::public_root, 32); auto crypto_hash = digest::sha256(crypto_chain_data); /* suspecius, tries the server to hide himself? We dont know */ @@ -170,17 +170,12 @@ void ProtocolHandler::handleCommandInitIVExpend2(ts::Command &cmd) { return; } - if(crypto_root.length() != 32) { - this->handle->call_connect_result.call(this->handle->errors.register_error(tr("invalid crypto chain root! (Invalid length)")), true); - this->handle->close_connection(); - return; - } - auto server_public_key = crypto_chain->generatePublicKey(*(license::teamspeak::LicensePublicKey*) crypto_root.data()); crypto_chain->print(); u_char seed[32]; - u_char public_key[32], private_key[64]; /* private keys are only 32 bits long, but the SHA512 of the seed is 64 bytes! */ + ed25519_create_seed(seed); + u_char public_key[32], private_key[64]; /* We need 64 bytes because we're doing some SHA512 actions */ ed25519_create_keypair(public_key, private_key, seed); /* send clientek response */ @@ -214,8 +209,8 @@ void ProtocolHandler::handleCommandInitIVExpend2(ts::Command &cmd) { if(!this->crypt_handler.setupSharedSecretNew(string((char*) this->crypto.alpha, 10), beta, (char*) private_key, server_public_key.data())) { - this->handle->call_connect_result.call(this->handle->errors.register_error(tr("failed to setup encryption (II)")), true); + this->handle->call_connect_result.call(this->handle->errors.register_error(tr("failed to setup encryption")), true); this->handle->close_connection(); return; } -} \ No newline at end of file +} diff --git a/package.json b/package.json index b581b23..4896fbc 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "crash_handler": "electron . crash-handler", "test": "echo \"Error: no test specified\" && exit 1", "start": "electron --js-flags='--expose-gc' --debug --dev-tools --disable-hardware-acceleration .", - "start-d": "electron . --debug -t -su http://dev.clientapi.teaspeak.de/", + "start-d": "electron . --debug -t --gdb -su http://dev.clientapi.teaspeak.de/", "start-n": "electron . -t --no-single-instance -su http://null.teaspeak.de/", "start-01": "electron . --updater-channel=test -u=http://dev.clientapi.teaspeak.de/ -d --updater-ui-loader_type=0 --updater-local-version=1.0.1", "compile-sass": "sass --update .:.",