From 3e59e21a0e9da50f8ee85a5bd86e03e4e0bdde9e Mon Sep 17 00:00:00 2001 From: WolverinDEV Date: Mon, 8 Jul 2019 11:07:57 +0200 Subject: [PATCH] Updates --- installer/package.ts | 1 + modules/renderer/connection/ServerConnection.ts | 5 +++-- .../src/connection/ProtocolHandlerCrypto.cpp | 17 ++++++++++++----- native/serverconnection/test/js/main.ts | 9 +++++++-- 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/installer/package.ts b/installer/package.ts index f12a447..ada188f 100644 --- a/installer/package.ts +++ b/installer/package.ts @@ -136,6 +136,7 @@ export async function deploy(platform: string, arch: string, channel: string, ve console.log("Secret (env key: teaclient_deploy_secret): " + process.env["teaclient_deploy_secret"]); if(!process.env["teaclient_deploy_secret"]) throw "Missing secret!"; + request.post(url, { formData: { type: "deploy-build", diff --git a/modules/renderer/connection/ServerConnection.ts b/modules/renderer/connection/ServerConnection.ts index 4b89b22..e6f9339 100644 --- a/modules/renderer/connection/ServerConnection.ts +++ b/modules/renderer/connection/ServerConnection.ts @@ -183,9 +183,10 @@ export namespace _connection { callback: error => { - if(error != 0) + if(error != 0) { reject(this._native_handle.error_message(error)); - else { + return; + } else { resolve(); } diff --git a/native/serverconnection/src/connection/ProtocolHandlerCrypto.cpp b/native/serverconnection/src/connection/ProtocolHandlerCrypto.cpp index b5730d3..4ed22b6 100644 --- a/native/serverconnection/src/connection/ProtocolHandlerCrypto.cpp +++ b/native/serverconnection/src/connection/ProtocolHandlerCrypto.cpp @@ -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")), true); + this->handle->call_connect_result.call(this->handle->errors.register_error(tr("failed to setup encryption (I)")), 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"]) : string((char*) license::teamspeak::public_root, 32); + auto crypto_root = cmd[0].has("root") ? base64::decode(cmd["root"]) : std::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,11 +170,17 @@ 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 * 2]; //FIXME more secure - u_char public_key[32], private_key[32]; + 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_keypair(public_key, private_key, seed); /* send clientek response */ @@ -206,8 +212,9 @@ void ProtocolHandler::handleCommandInitIVExpend2(ts::Command &cmd) { }); /* needs to be encrypted at the time! */ } + 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")), true); + this->handle->call_connect_result.call(this->handle->errors.register_error(tr("failed to setup encryption (II)")), true); this->handle->close_connection(); return; } diff --git a/native/serverconnection/test/js/main.ts b/native/serverconnection/test/js/main.ts index 5ad3e3d..0445eff 100644 --- a/native/serverconnection/test/js/main.ts +++ b/native/serverconnection/test/js/main.ts @@ -103,8 +103,9 @@ const do_connect = () => { connection.connect({ timeout: 5000, remote_port: 9987, - //remote_host: "localhost", - remote_host: "ts.teaspeak.de", + //remote_host: "188.40.240.20", /* twerion */ + remote_host: "localhost", + //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 */ @@ -159,6 +160,10 @@ const do_connect = () => { connection.callback_voice_data = (buffer, client_id, codec_id, flag_head, packet_id) => { connection.send_voice_data(buffer, codec_id, flag_head); } + + connection.callback_command = (command, arguments1, switches) => { + console.log("Command: %s", command); + } }; do_connect();