Updated the logging system

This commit is contained in:
WolverinDEV
2019-11-23 21:16:55 +01:00
parent b7d60361c0
commit fb5dc72970
28 changed files with 135 additions and 104 deletions
+2 -2
View File
@@ -42,7 +42,7 @@ VoiceClient::~VoiceClient() {
this->connection = nullptr;
if(this->flushing_thread)
logCritical(0, "Deleting a VoiceClient which should still be hold within the flush thread!");
logCritical(this->getServerId(), "Deleting a VoiceClient which should still be hold within the flush thread!");
memtrack::freed<VoiceClient>(this);
}
@@ -50,7 +50,7 @@ VoiceClient::~VoiceClient() {
void VoiceClient::sendCommand0(const ts::Command &command, bool low, bool direct, std::unique_ptr<threads::Future<bool>> listener) {
auto cmd = command.build();
if(cmd.empty()) {
logCritical("Attempted to send an empty command!");
logCritical(this->getServerId(), "{} Attempted to send an empty command!", CLIENT_STR_LOG_PREFIX);
return;
}
@@ -29,13 +29,11 @@ CommandResult VoiceClient::handleCommand(ts::Command &command) {
return SpeakingClient::handleCommand(command);
}
inline int getSecurityLevel(ecc_key* pubKey, size_t offset) {
inline bool calculate_security_level(int& result, ecc_key* pubKey, size_t offset) {
size_t pubLength = 256;
char pubBuffer[256];
if(ecc_export(reinterpret_cast<unsigned char *>(pubBuffer), &pubLength, PK_PUBLIC, pubKey) != CRYPT_OK){
logError(lstream << "failed to export pub key" << endl);
return -1;
}
if((result = ecc_export(reinterpret_cast<unsigned char *>(pubBuffer), &pubLength, PK_PUBLIC, pubKey)) != CRYPT_OK)
return false;
std::string hashStr = base64_encode(pubBuffer, pubLength) + to_string(offset);
char shaBuffer[SHA_DIGEST_LENGTH];
@@ -53,7 +51,8 @@ inline int getSecurityLevel(ecc_key* pubKey, size_t offset) {
else break;
}
}
return zeroBits;
result = zeroBits;
return true;
}
CommandResult VoiceClient::handleCommandClientInit(Command &cmd) {
@@ -61,7 +60,11 @@ CommandResult VoiceClient::handleCommandClientInit(Command &cmd) {
this->connection->acknowledge_handler.reset();
if(this->getType() == ClientType::CLIENT_TEAMSPEAK) {
auto securityLevel = getSecurityLevel(this->crypto.remote_key.get(), cmd["client_key_offset"]);
int securityLevel;
if(!calculate_security_level(securityLevel, this->crypto.remote_key.get(), cmd["client_key_offset"])) {
logError(this->getServerId(), "[{}] Failed to calculate security level. Error code: {}", CLIENT_STR_LOG_PREFIX, securityLevel);
return {ErrorType::VSError};
}
if(securityLevel < 8)
return {findError("channel_invalid_security_hash"), "cant calculate security level"};