Fixed some stuff

This commit is contained in:
WolverinDEV 2019-07-08 11:16:18 +02:00
commit 5c41277871
5 changed files with 36 additions and 16 deletions

View File

@ -9,6 +9,6 @@
"./deploy/",
"build.ts",
"package.ts",
"package_linux.ts"
"package_windows.ts"
]
}
}

View File

@ -4,6 +4,7 @@
#include <iostream>
#include <mutex>
#include <event2/thread.h>
#include <misc/digest.h>
#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<v8::String>(key).ToLocalChecked(), Nan::New<v8::Number>(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");

View File

@ -444,6 +444,7 @@ bool ProtocolHandler::create_datagram_packets(std::vector<pipes::buffer> &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);

View File

@ -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;
}
}
}

View File

@ -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 .:.",