License server memory validation

This commit is contained in:
WolverinDEV 2020-04-03 19:07:03 +02:00
parent 240052da3a
commit 8e4d52ddd2
9 changed files with 28 additions and 7 deletions

@ -1 +1 @@
Subproject commit 9f4f5e72a7fc35d0c9e7faf1678cd168daf90ab9 Subproject commit f7d60a93a2c2c5a1e4cd87717d89f014a74e97ef

View File

@ -198,6 +198,10 @@ bool LicenseServer::handleServerValidation(shared_ptr<ConnectedClient> &client,
} }
} }
this->manager->logRequest(remote_license->key(), client->unique_identifier, client->address(), pkt.info().version(), response.valid()); this->manager->logRequest(remote_license->key(), client->unique_identifier, client->address(), pkt.info().version(), response.valid());
} else if(pkt.has_memory_valid() && !pkt.memory_valid()) {
response.set_invalid_reason("server memory seems to be invalid");
response.set_valid(false);
logError(LOG_GENERAL, "Server {} has patched license memory!", client->address());
} else { } else {
response.set_valid(true); response.set_valid(true);
} }

View File

@ -41,6 +41,7 @@ message ServerValidation {
required bool license_info = 2; required bool license_info = 2;
optional bytes license = 3; optional bytes license = 3;
optional ServerInfo info = 4; //Change somewhere to required but its currently for legacy support optional ServerInfo info = 4; //Change somewhere to required but its currently for legacy support
optional bool memory_valid = 5;
} }
message LicenseResponse { message LicenseResponse {

View File

@ -517,7 +517,7 @@ vector<string> config::parseConfig(const std::string& path) {
} }
} }
auto currentVersion = strobf("TeaSpeak ").string() + build::version()->string(true); auto currentVersion = config::server::default_version();
if(currentVersion != config::server::DefaultServerVersion) { if(currentVersion != config::server::DefaultServerVersion) {
auto ref = config::server::DefaultServerVersion; auto ref = config::server::DefaultServerVersion;
try { try {

View File

@ -7,8 +7,10 @@
#undef byte #undef byte
#endif #endif
#include <spdlog/common.h> #include <spdlog/common.h>
#include <misc/strobf.h>
#include "geo/GeoLocation.h" #include "geo/GeoLocation.h"
#include "../../license/shared/include/license/license.h" #include "../../license/shared/include/license/license.h"
#include "build.h"
namespace YAML { namespace YAML {
class Node; class Node;
@ -108,6 +110,12 @@ namespace ts::config {
} }
extern ssize_t max_virtual_server; extern ssize_t max_virtual_server;
__attribute__((always_inline)) inline std::string default_version() { return strobf("TeaSpeak ").string() + build::version()->string(true); }
__attribute__((always_inline)) inline bool check_server_version_with_license() {
auto currentVersion = config::server::default_version();
return currentVersion == DefaultServerVersion || (license->isPremium() && license->isValid());
}
} }
namespace voice { namespace voice {

View File

@ -381,7 +381,7 @@ bool ConnectedClient::notifyClientLeftView(
std::shared_ptr<ConnectedClient> invoker, std::shared_ptr<ConnectedClient> invoker,
bool lock_channel_tree) { bool lock_channel_tree) {
assert(!lock_channel_tree); /* not supported yet! */ assert(!lock_channel_tree); /* not supported yet! */
assert(client && client->getClientId() != 0); assert(client && client != this && client->getClientId() != 0);
assert(client->currentChannel || &*client == this); assert(client->currentChannel || &*client == this);
if(client != this) { if(client != this) {

View File

@ -177,6 +177,10 @@ void VoiceBridge::handle_media_stream(const std::shared_ptr<rtc::Channel> &undef
if(!stream) return; if(!stream) return;
this->_audio_channel = stream; this->_audio_channel = stream;
for(const auto& ex : stream->list_extensions()) {
debugMessage(0, "{} | {}", ex->name, ex->id);
}
stream->register_local_extension("urn:ietf:params:rtp-hdrext:ssrc-audio-level"); stream->register_local_extension("urn:ietf:params:rtp-hdrext:ssrc-audio-level");
for(const auto& codec : stream->list_codecs()) { for(const auto& codec : stream->list_codecs()) {
if(codec->type == rtc::codec::Codec::OPUS) { if(codec->type == rtc::codec::Codec::OPUS) {

View File

@ -172,6 +172,9 @@ void LicenseService::handle_check_succeeded() {
} else { } else {
logMessage(LOG_INSTANCE, strobf("Instance integrity has been validated.").string()); logMessage(LOG_INSTANCE, strobf("Instance integrity has been validated.").string());
} }
if(!config::server::check_server_version_with_license())
handle_check_fail(strobf("memory invalid").string());
} }
{ {
@ -191,9 +194,10 @@ void LicenseService::handle_check_fail(const std::string &error) {
this->timings.last_succeeded.time_since_epoch().count() == 0 ? this->timings.failed_count < 32 : /* About 12hours */ this->timings.last_succeeded.time_since_epoch().count() == 0 ? this->timings.failed_count < 32 : /* About 12hours */
this->timings.failed_count < 82 /* about 36 hours */ this->timings.failed_count < 82 /* about 36 hours */
); );
if(config::license->isPremium() && !soft_license_check) { const auto invalid_memory = !config::server::check_server_version_with_license();
if(invalid_memory || (config::license->isPremium() && !soft_license_check)) {
logCritical(LOG_INSTANCE, strobf("Failed to validate license:").string()); logCritical(LOG_INSTANCE, strobf("Failed to validate license:").string());
logCritical(LOG_INSTANCE, error); logCritical(LOG_INSTANCE, invalid_memory ? strobf("invalid memory").string() : error);
logCritical(LOG_INSTANCE, strobf("Stopping server!").string()); logCritical(LOG_INSTANCE, strobf("Stopping server!").string());
ts::server::shutdownInstance(); ts::server::shutdownInstance();
} else { } else {
@ -305,11 +309,11 @@ void LicenseService::send_license_validate_request() {
request.set_licensed(false); request.set_licensed(false);
request.set_license_info(false); request.set_license_info(false);
} }
request.set_memory_valid(config::server::check_server_version_with_license());
request.mutable_info()->set_uname(this->license_request_data->info.uname); request.mutable_info()->set_uname(this->license_request_data->info.uname);
request.mutable_info()->set_version(this->license_request_data->info.version); request.mutable_info()->set_version(this->license_request_data->info.version);
request.mutable_info()->set_timestamp(this->license_request_data->info.timestamp.count()); request.mutable_info()->set_timestamp(this->license_request_data->info.timestamp.count());
request.mutable_info()->set_unique_id(this->license_request_data->info.unique_id); request.mutable_info()->set_unique_id(this->license_request_data->info.unique_id);
this->client_send_message(::license::protocol::PACKET_CLIENT_SERVER_VALIDATION, request); this->client_send_message(::license::protocol::PACKET_CLIENT_SERVER_VALIDATION, request);
} }

2
shared

@ -1 +1 @@
Subproject commit fab6aa90954bc85efad8a0b5a3608cb408202a17 Subproject commit e1e946ca359f65fff5e19583ff1c9711a3143460