From fc365736ed43e7989d2be811e6700f9c4661540f Mon Sep 17 00:00:00 2001 From: WolverinDEV Date: Tue, 29 Oct 2019 16:06:34 +0100 Subject: [PATCH] Updates for 1.4.1 --- git-teaspeak | 2 +- server/CMakeLists.txt | 2 +- server/src/Group.cpp | 6 +++--- server/src/Group.h | 2 +- server/src/TS3ServerClientManager.cpp | 9 ++++++--- server/src/TSServer.cpp | 2 +- .../src/client/ConnectedClientCommandHandler.cpp | 15 ++++++++------- .../src/client/ConnectedClientNotifyHandler.cpp | 2 +- server/src/client/SpeakingClient.cpp | 3 +-- server/src/client/music/MusicClient.h | 1 + server/src/weblist/TeamSpeakWebClient.h | 2 +- server/src/weblist/WebListManager.cpp | 6 +++++- 12 files changed, 30 insertions(+), 22 deletions(-) diff --git a/git-teaspeak b/git-teaspeak index 819ba6d..ebc3c78 160000 --- a/git-teaspeak +++ b/git-teaspeak @@ -1 +1 @@ -Subproject commit 819ba6d0903e1d102fff5921669d223ed72982c4 +Subproject commit ebc3c785535cbacb2956b266519f22f65ef88f78 diff --git a/server/CMakeLists.txt b/server/CMakeLists.txt index 0ae7687..5d9d225 100644 --- a/server/CMakeLists.txt +++ b/server/CMakeLists.txt @@ -229,7 +229,7 @@ target_link_libraries(PermMapHelper SET(CPACK_PACKAGE_VERSION_MAJOR "1") SET(CPACK_PACKAGE_VERSION_MINOR "4") -SET(CPACK_PACKAGE_VERSION_PATCH "0") +SET(CPACK_PACKAGE_VERSION_PATCH "1") if(BUILD_TYPE_NAME EQUAL OFF) SET(CPACK_PACKAGE_VERSION_DATA "beta") elseif(BUILD_TYPE_NAME STREQUAL "") diff --git a/server/src/Group.cpp b/server/src/Group.cpp index b19efd0..c2524aa 100644 --- a/server/src/Group.cpp +++ b/server/src/Group.cpp @@ -440,7 +440,7 @@ int64_t GroupManager::generateGroupId(sql::SqlManager* sql) { return hightestGroupId + 1; } -std::deque GroupManager::update_server_group_property(const shared_ptr &client, bool channel_lock) { +std::deque GroupManager::update_server_group_property(const shared_ptr &client, bool channel_lock, const std::shared_ptr& channel) { std::deque changed; //Server groups @@ -467,8 +467,8 @@ std::deque GroupManager::update_server_group_propert } //Channel groups - if(client->getChannel()){ - shared_ptr group = this->getChannelGroup(client->getClientDatabaseId(), client->getChannel(), true); + if(channel){ + shared_ptr group = this->getChannelGroup(client->getClientDatabaseId(), channel, true); if(client->properties()[property::CLIENT_CHANNEL_GROUP_INHERITED_CHANNEL_ID] != group->channelId) { client->properties()[property::CLIENT_CHANNEL_GROUP_INHERITED_CHANNEL_ID] = group->channelId; changed.push_back(property::CLIENT_CHANNEL_GROUP_INHERITED_CHANNEL_ID); diff --git a/server/src/Group.h b/server/src/Group.h index 0c8d418..07f9f03 100644 --- a/server/src/Group.h +++ b/server/src/Group.h @@ -209,7 +209,7 @@ namespace ts { std::shared_ptr defaultGroup(GroupTarget type, bool enforce_property = false); - std::deque update_server_group_property(const std::shared_ptr &client, bool channel_lock); + std::deque update_server_group_property(const std::shared_ptr &client, bool channel_lock, const std::shared_ptr& channel); void enableCache(const ClientDbId& /* client database id */); /* if this called disableCache(...) MUST be called to decrease the reference count */ void disableCache(const ClientDbId& /* client database id */); bool isClientCached(const ClientDbId& /* client database id */); diff --git a/server/src/TS3ServerClientManager.cpp b/server/src/TS3ServerClientManager.cpp index 265b2c7..98cdafa 100644 --- a/server/src/TS3ServerClientManager.cpp +++ b/server/src/TS3ServerClientManager.cpp @@ -386,6 +386,8 @@ void TSServer::client_move( auto s_source_channel = dynamic_pointer_cast(target->currentChannel); assert(!target->currentChannel || s_source_channel != nullptr); + deque client_updates; + std::deque changed_groups{}; if(target_channel) { assert(s_target_channel); if(s_target_channel->deleted) { @@ -393,6 +395,10 @@ void TSServer::client_move( s_target_channel = dynamic_pointer_cast(target_channel); assert(s_target_channel); } + + /* update the group properties here already, so for all enter views we could just send the new props directly */ + changed_groups = this->groups->update_server_group_property(target, true, s_target_channel); + client_updates.insert(client_updates.end(), changed_groups.begin(), changed_groups.end()); //TODO: Only update for clients which have no enter? } auto l_target_channel = s_target_channel ? this->channelTree->findLinkedChannel(s_target_channel->channelId()) : nullptr; auto l_source_channel = s_source_channel ? this->channelTree->findLinkedChannel(s_source_channel->channelId()) : nullptr; @@ -486,7 +492,6 @@ void TSServer::client_move( unique_lock client_channel_lock(target->channel_lock); TIMING_STEP(timings, "lock own tr"); - deque client_updates; if (s_source_channel) { s_source_channel->properties()[property::CHANNEL_LAST_LEFT] = chrono::duration_cast(chrono::system_clock::now().time_since_epoch()).count(); auto source_channel_group = this->groups->getChannelGroupExact(target->getClientDatabaseId(), s_source_channel, false); @@ -509,10 +514,8 @@ void TSServer::client_move( } if (s_target_channel) { - auto changed_groups = this->groups->update_server_group_property(target, false); if(target->update_cached_permissions()) /* update cached calculated permissions */ target->sendNeededPermissions(false); - client_updates.insert(client_updates.end(), changed_groups.begin(), changed_groups.end()); TIMING_STEP(timings, "perm gr upd"); if(s_source_channel) { diff --git a/server/src/TSServer.cpp b/server/src/TSServer.cpp index d0bc696..664224c 100644 --- a/server/src/TSServer.cpp +++ b/server/src/TSServer.cpp @@ -1152,7 +1152,7 @@ bool TSServer::resetPermissions(std::string& token) { client->notifyServerGroupList(); client->notifyChannelGroupList(); } - if(this->notifyClientPropertyUpdates(client, this->getGroupManager()->update_server_group_property(client, true))) { + if(this->notifyClientPropertyUpdates(client, this->getGroupManager()->update_server_group_property(client, true, client->getChannel()))) { if(client->update_cached_permissions()) /* update cached calculated permissions */ client->sendNeededPermissions(false); /* cached permissions had changed, notify the client */ } diff --git a/server/src/client/ConnectedClientCommandHandler.cpp b/server/src/client/ConnectedClientCommandHandler.cpp index f9b90df..af6410e 100644 --- a/server/src/client/ConnectedClientCommandHandler.cpp +++ b/server/src/client/ConnectedClientCommandHandler.cpp @@ -576,7 +576,7 @@ CommandResult ConnectedClient::handleCommandServerEdit(Command &cmd) { if(target_server) { if (group_update) target_server->forEachClient([&](const shared_ptr& client) { - if(target_server->notifyClientPropertyUpdates(client, target_server->groups->update_server_group_property(client, true))) { + if(target_server->notifyClientPropertyUpdates(client, target_server->groups->update_server_group_property(client, true, client->getChannel()))) { if(client->update_cached_permissions()) /* update cached calculated permissions */ client->sendNeededPermissions(false); /* cached permissions had changed, notify the client */ } @@ -1119,7 +1119,7 @@ CommandResult ConnectedClient::handleCommandChannelGroupDel(Command &cmd) { if (group_manager->deleteGroup(channel_group) && this->server) { this->server->forEachClient([&](shared_ptr cl) { - if(this->server->notifyClientPropertyUpdates(cl, this->server->groups->update_server_group_property(cl, true))) { + if(this->server->notifyClientPropertyUpdates(cl, this->server->groups->update_server_group_property(cl, true, cl->getChannel()))) { if(cl->update_cached_permissions()) /* update cached calculated permissions */ cl->sendNeededPermissions(false); /* cached permissions had changed, notify the client */ } @@ -2788,7 +2788,7 @@ CommandResult ConnectedClient::handleCommandServerGroupDel(Command &cmd) { if (group_manager->deleteGroup(serverGroup)) { if(this->server) this->server->forEachClient([&](shared_ptr cl) { - if(this->server->notifyClientPropertyUpdates(cl, this->server->groups->update_server_group_property(cl, true))) { + if(this->server->notifyClientPropertyUpdates(cl, this->server->groups->update_server_group_property(cl, true, cl->getChannel()))) { if(cl->update_cached_permissions()) /* update cached calculated permissions */ cl->sendNeededPermissions(false); /* cached permissions had changed, notify the client */ } @@ -2926,7 +2926,7 @@ CommandResult ConnectedClient::handleCommandServerGroupAddClient(Command &cmd) { for(const auto& _server : target_server ? std::deque>{target_server} : serverInstance->getVoiceServerManager()->serverInstances()) { for (const auto &targetClient : _server->findClientsByCldbId(target_cldbid)) { - if (_server->notifyClientPropertyUpdates(targetClient, _server->groups->update_server_group_property(targetClient, true))) { + if (_server->notifyClientPropertyUpdates(targetClient, _server->groups->update_server_group_property(targetClient, true, targetClient->getChannel()))) { for (const auto &client : _server->getClients()) { if(client->isClientVisible(targetClient, true) || client == targetClient) for(const auto& group : applied_groups) @@ -3053,7 +3053,7 @@ CommandResult ConnectedClient::handleCommandServerGroupDelClient(Command &cmd) { for(const auto& _server : target_server ? std::deque>{target_server} : serverInstance->getVoiceServerManager()->serverInstances()) { for (const auto &targetClient : _server->findClientsByCldbId(target_cldbid)) { - if (_server->notifyClientPropertyUpdates(targetClient, _server->groups->update_server_group_property(targetClient, true))) { + if (_server->notifyClientPropertyUpdates(targetClient, _server->groups->update_server_group_property(targetClient, true, targetClient->getChannel()))) { for (const auto &client : _server->getClients()) { if(client->isClientVisible(targetClient, true) || client == targetClient) for(const auto& group : applied_groups) @@ -3470,7 +3470,7 @@ CommandResult ConnectedClient::handleCommandSetClientChannelGroup(Command &cmd) for (const auto &targetClient : this->server->findClientsByCldbId(target_cldbid)) { unique_lock client_channel_lock_w(targetClient->channel_lock); - auto updates = this->server->groups->update_server_group_property(targetClient, false); /* needs a write lock */ + auto updates = this->server->groups->update_server_group_property(targetClient, false, targetClient->getChannel()); /* needs a write lock */ client_channel_lock_w.unlock(); shared_lock client_channel_lock_r(targetClient->channel_lock); auto result = this->server->notifyClientPropertyUpdates(targetClient, updates); @@ -4504,7 +4504,7 @@ CommandResult ConnectedClient::handleCommandTokenUse(Command &cmd) { } } - if (this->server->notifyClientPropertyUpdates(_this.lock(), this->server->groups->update_server_group_property(_this.lock(), true))) { + if (this->server->notifyClientPropertyUpdates(_this.lock(), this->server->groups->update_server_group_property(_this.lock(), true, this->getChannel()))) { if(this->update_cached_permissions()) /* update cached calculated permissions */ this->sendNeededPermissions(false); /* cached permissions had changed, notify the client */ @@ -6548,6 +6548,7 @@ CommandResult ConnectedClient::handleCommandMusicBotCreate(Command& cmd) { server_channel_w_lock ); } + bot->properties()[property::CLIENT_LAST_CHANNEL] = channel ? channel->channelId() : 0; if(permissions[permission::i_client_music_delete_power] > 0) { bot->clientPermissions->set_permission(permission::i_client_music_needed_delete_power, {permissions[permission::i_client_music_delete_power],0}, permission::v2::set_value, permission::v2::do_nothing); diff --git a/server/src/client/ConnectedClientNotifyHandler.cpp b/server/src/client/ConnectedClientNotifyHandler.cpp index 84157a4..9b8a9c9 100644 --- a/server/src/client/ConnectedClientNotifyHandler.cpp +++ b/server/src/client/ConnectedClientNotifyHandler.cpp @@ -396,7 +396,7 @@ bool ConnectedClient::notifyClientUpdated(const std::shared_ptr logError(this->getServerId(), "{} Attempted to send a clientupdate for client id 0. Updated client: {}", CLIENT_STR_LOG_PREFIX, CLIENT_STR_LOG_PREFIX_(client)); return false; } - Command response(this->getExternalType() == ClientType::CLIENT_TEAMSPEAK ? "notifyclientupdated" : ""); + Command response("notifyclientupdated"); response["clid"] = client_id; for (const auto &prop : props) { if(lastOnlineTimestamp.time_since_epoch().count() > 0 && (prop->property_index == property::CLIENT_TOTAL_ONLINE_TIME || prop->property_index == property::CLIENT_MONTH_ONLINE_TIME)) diff --git a/server/src/client/SpeakingClient.cpp b/server/src/client/SpeakingClient.cpp index 3b6127d..7c54e79 100644 --- a/server/src/client/SpeakingClient.cpp +++ b/server/src/client/SpeakingClient.cpp @@ -634,7 +634,7 @@ void SpeakingClient::processJoin() { TIMING_STEP(timings, "server reg "); ref_server->getGroupManager()->cleanupAssignments(this->getClientDatabaseId()); TIMING_STEP(timings, "grp cleanup"); - ref_server->getGroupManager()->update_server_group_property(_this.lock(), true); + ref_server->getGroupManager()->update_server_group_property(_this.lock(), true, nullptr); TIMING_STEP(timings, "grp apply "); this->properties()[property::CLIENT_COUNTRY] = config::geo::countryFlag; @@ -680,7 +680,6 @@ void SpeakingClient::processJoin() { this->currentChannel = nullptr; { /* enforce an update of these properties */ - this->properties()[property::CLIENT_SERVERGROUPS] = "0"; this->properties()[property::CLIENT_CHANNEL_GROUP_INHERITED_CHANNEL_ID] = "0"; this->properties()[property::CLIENT_CHANNEL_GROUP_ID] = "0"; this->properties()[property::CLIENT_TALK_POWER] = "0"; diff --git a/server/src/client/music/MusicClient.h b/server/src/client/music/MusicClient.h index c45ad08..62026ad 100644 --- a/server/src/client/music/MusicClient.h +++ b/server/src/client/music/MusicClient.h @@ -96,6 +96,7 @@ namespace ts { bool lock_channel_tree ) override; + protected: void broadcast_text_message(const std::string &message); diff --git a/server/src/weblist/TeamSpeakWebClient.h b/server/src/weblist/TeamSpeakWebClient.h index 8d3254b..23634d2 100644 --- a/server/src/weblist/TeamSpeakWebClient.h +++ b/server/src/weblist/TeamSpeakWebClient.h @@ -40,7 +40,7 @@ namespace ts { sockaddr_in remote_address{}; std::mutex write_lock; std::deque write_buffer{}; - int file_descriptor; + int file_descriptor{0}; struct event* event_read = nullptr; struct event* event_write = nullptr; diff --git a/server/src/weblist/WebListManager.cpp b/server/src/weblist/WebListManager.cpp index 7001eeb..7094819 100644 --- a/server/src/weblist/WebListManager.cpp +++ b/server/src/weblist/WebListManager.cpp @@ -128,7 +128,11 @@ void WebListManager::tick() { _entry->current_request.reset(); }; - entry->current_request->report(); + { + /* could be blocking due to gethostbyname. We dont want to have the request deallocated */ + auto ref_request = entry->current_request; + ref_request->report(); + } } } } \ No newline at end of file