Updates for 1.4.1

This commit is contained in:
WolverinDEV 2019-10-29 16:06:34 +01:00
parent 0b2ec5ac0a
commit fc365736ed
12 changed files with 30 additions and 22 deletions

@ -1 +1 @@
Subproject commit 819ba6d0903e1d102fff5921669d223ed72982c4 Subproject commit ebc3c785535cbacb2956b266519f22f65ef88f78

View File

@ -229,7 +229,7 @@ target_link_libraries(PermMapHelper
SET(CPACK_PACKAGE_VERSION_MAJOR "1") SET(CPACK_PACKAGE_VERSION_MAJOR "1")
SET(CPACK_PACKAGE_VERSION_MINOR "4") SET(CPACK_PACKAGE_VERSION_MINOR "4")
SET(CPACK_PACKAGE_VERSION_PATCH "0") SET(CPACK_PACKAGE_VERSION_PATCH "1")
if(BUILD_TYPE_NAME EQUAL OFF) if(BUILD_TYPE_NAME EQUAL OFF)
SET(CPACK_PACKAGE_VERSION_DATA "beta") SET(CPACK_PACKAGE_VERSION_DATA "beta")
elseif(BUILD_TYPE_NAME STREQUAL "") elseif(BUILD_TYPE_NAME STREQUAL "")

View File

@ -440,7 +440,7 @@ int64_t GroupManager::generateGroupId(sql::SqlManager* sql) {
return hightestGroupId + 1; return hightestGroupId + 1;
} }
std::deque<property::ClientProperties> GroupManager::update_server_group_property(const shared_ptr<server::ConnectedClient> &client, bool channel_lock) { std::deque<property::ClientProperties> GroupManager::update_server_group_property(const shared_ptr<server::ConnectedClient> &client, bool channel_lock, const std::shared_ptr<BasicChannel>& channel) {
std::deque<property::ClientProperties> changed; std::deque<property::ClientProperties> changed;
//Server groups //Server groups
@ -467,8 +467,8 @@ std::deque<property::ClientProperties> GroupManager::update_server_group_propert
} }
//Channel groups //Channel groups
if(client->getChannel()){ if(channel){
shared_ptr<GroupAssignment> group = this->getChannelGroup(client->getClientDatabaseId(), client->getChannel(), true); shared_ptr<GroupAssignment> group = this->getChannelGroup(client->getClientDatabaseId(), channel, true);
if(client->properties()[property::CLIENT_CHANNEL_GROUP_INHERITED_CHANNEL_ID] != group->channelId) { if(client->properties()[property::CLIENT_CHANNEL_GROUP_INHERITED_CHANNEL_ID] != group->channelId) {
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); changed.push_back(property::CLIENT_CHANNEL_GROUP_INHERITED_CHANNEL_ID);

View File

@ -209,7 +209,7 @@ namespace ts {
std::shared_ptr<Group> defaultGroup(GroupTarget type, bool enforce_property = false); std::shared_ptr<Group> defaultGroup(GroupTarget type, bool enforce_property = false);
std::deque<property::ClientProperties> update_server_group_property(const std::shared_ptr<server::ConnectedClient> &client, bool channel_lock); std::deque<property::ClientProperties> update_server_group_property(const std::shared_ptr<server::ConnectedClient> &client, bool channel_lock, const std::shared_ptr<BasicChannel>& channel);
void enableCache(const ClientDbId& /* client database id */); /* if this called disableCache(...) MUST be called to decrease the reference count */ 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 */); void disableCache(const ClientDbId& /* client database id */);
bool isClientCached(const ClientDbId& /* client database id */); bool isClientCached(const ClientDbId& /* client database id */);

View File

@ -386,6 +386,8 @@ void TSServer::client_move(
auto s_source_channel = dynamic_pointer_cast<ServerChannel>(target->currentChannel); auto s_source_channel = dynamic_pointer_cast<ServerChannel>(target->currentChannel);
assert(!target->currentChannel || s_source_channel != nullptr); assert(!target->currentChannel || s_source_channel != nullptr);
deque<property::ClientProperties> client_updates;
std::deque<property::ClientProperties> changed_groups{};
if(target_channel) { if(target_channel) {
assert(s_target_channel); assert(s_target_channel);
if(s_target_channel->deleted) { if(s_target_channel->deleted) {
@ -393,6 +395,10 @@ void TSServer::client_move(
s_target_channel = dynamic_pointer_cast<ServerChannel>(target_channel); s_target_channel = dynamic_pointer_cast<ServerChannel>(target_channel);
assert(s_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_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; 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); unique_lock client_channel_lock(target->channel_lock);
TIMING_STEP(timings, "lock own tr"); TIMING_STEP(timings, "lock own tr");
deque<property::ClientProperties> client_updates;
if (s_source_channel) { if (s_source_channel) {
s_source_channel->properties()[property::CHANNEL_LAST_LEFT] = chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now().time_since_epoch()).count(); s_source_channel->properties()[property::CHANNEL_LAST_LEFT] = chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now().time_since_epoch()).count();
auto source_channel_group = this->groups->getChannelGroupExact(target->getClientDatabaseId(), s_source_channel, false); 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) { if (s_target_channel) {
auto changed_groups = this->groups->update_server_group_property(target, false);
if(target->update_cached_permissions()) /* update cached calculated permissions */ if(target->update_cached_permissions()) /* update cached calculated permissions */
target->sendNeededPermissions(false); target->sendNeededPermissions(false);
client_updates.insert(client_updates.end(), changed_groups.begin(), changed_groups.end());
TIMING_STEP(timings, "perm gr upd"); TIMING_STEP(timings, "perm gr upd");
if(s_source_channel) { if(s_source_channel) {

View File

@ -1152,7 +1152,7 @@ bool TSServer::resetPermissions(std::string& token) {
client->notifyServerGroupList(); client->notifyServerGroupList();
client->notifyChannelGroupList(); 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 */ if(client->update_cached_permissions()) /* update cached calculated permissions */
client->sendNeededPermissions(false); /* cached permissions had changed, notify the client */ client->sendNeededPermissions(false); /* cached permissions had changed, notify the client */
} }

View File

@ -576,7 +576,7 @@ CommandResult ConnectedClient::handleCommandServerEdit(Command &cmd) {
if(target_server) { if(target_server) {
if (group_update) if (group_update)
target_server->forEachClient([&](const shared_ptr<ConnectedClient>& client) { target_server->forEachClient([&](const shared_ptr<ConnectedClient>& 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 */ if(client->update_cached_permissions()) /* update cached calculated permissions */
client->sendNeededPermissions(false); /* cached permissions had changed, notify the client */ 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) { if (group_manager->deleteGroup(channel_group) && this->server) {
this->server->forEachClient([&](shared_ptr<ConnectedClient> cl) { this->server->forEachClient([&](shared_ptr<ConnectedClient> 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 */ if(cl->update_cached_permissions()) /* update cached calculated permissions */
cl->sendNeededPermissions(false); /* cached permissions had changed, notify the client */ 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 (group_manager->deleteGroup(serverGroup)) {
if(this->server) if(this->server)
this->server->forEachClient([&](shared_ptr<ConnectedClient> cl) { this->server->forEachClient([&](shared_ptr<ConnectedClient> 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 */ if(cl->update_cached_permissions()) /* update cached calculated permissions */
cl->sendNeededPermissions(false); /* cached permissions had changed, notify the client */ 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<shared_ptr<TSServer>>{target_server} : serverInstance->getVoiceServerManager()->serverInstances()) { for(const auto& _server : target_server ? std::deque<shared_ptr<TSServer>>{target_server} : serverInstance->getVoiceServerManager()->serverInstances()) {
for (const auto &targetClient : _server->findClientsByCldbId(target_cldbid)) { 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()) { for (const auto &client : _server->getClients()) {
if(client->isClientVisible(targetClient, true) || client == targetClient) if(client->isClientVisible(targetClient, true) || client == targetClient)
for(const auto& group : applied_groups) for(const auto& group : applied_groups)
@ -3053,7 +3053,7 @@ CommandResult ConnectedClient::handleCommandServerGroupDelClient(Command &cmd) {
for(const auto& _server : target_server ? std::deque<shared_ptr<TSServer>>{target_server} : serverInstance->getVoiceServerManager()->serverInstances()) { for(const auto& _server : target_server ? std::deque<shared_ptr<TSServer>>{target_server} : serverInstance->getVoiceServerManager()->serverInstances()) {
for (const auto &targetClient : _server->findClientsByCldbId(target_cldbid)) { 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()) { for (const auto &client : _server->getClients()) {
if(client->isClientVisible(targetClient, true) || client == targetClient) if(client->isClientVisible(targetClient, true) || client == targetClient)
for(const auto& group : applied_groups) for(const auto& group : applied_groups)
@ -3470,7 +3470,7 @@ CommandResult ConnectedClient::handleCommandSetClientChannelGroup(Command &cmd)
for (const auto &targetClient : this->server->findClientsByCldbId(target_cldbid)) { for (const auto &targetClient : this->server->findClientsByCldbId(target_cldbid)) {
unique_lock client_channel_lock_w(targetClient->channel_lock); 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(); client_channel_lock_w.unlock();
shared_lock client_channel_lock_r(targetClient->channel_lock); shared_lock client_channel_lock_r(targetClient->channel_lock);
auto result = this->server->notifyClientPropertyUpdates(targetClient, updates); 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 */ if(this->update_cached_permissions()) /* update cached calculated permissions */
this->sendNeededPermissions(false); /* cached permissions had changed, notify the client */ this->sendNeededPermissions(false); /* cached permissions had changed, notify the client */
@ -6548,6 +6548,7 @@ CommandResult ConnectedClient::handleCommandMusicBotCreate(Command& cmd) {
server_channel_w_lock server_channel_w_lock
); );
} }
bot->properties()[property::CLIENT_LAST_CHANNEL] = channel ? channel->channelId() : 0;
if(permissions[permission::i_client_music_delete_power] > 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); 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);

View File

@ -396,7 +396,7 @@ bool ConnectedClient::notifyClientUpdated(const std::shared_ptr<ConnectedClient>
logError(this->getServerId(), "{} Attempted to send a clientupdate for client id 0. Updated client: {}", CLIENT_STR_LOG_PREFIX, CLIENT_STR_LOG_PREFIX_(client)); 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; return false;
} }
Command response(this->getExternalType() == ClientType::CLIENT_TEAMSPEAK ? "notifyclientupdated" : ""); Command response("notifyclientupdated");
response["clid"] = client_id; response["clid"] = client_id;
for (const auto &prop : props) { 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)) if(lastOnlineTimestamp.time_since_epoch().count() > 0 && (prop->property_index == property::CLIENT_TOTAL_ONLINE_TIME || prop->property_index == property::CLIENT_MONTH_ONLINE_TIME))

View File

@ -634,7 +634,7 @@ void SpeakingClient::processJoin() {
TIMING_STEP(timings, "server reg "); TIMING_STEP(timings, "server reg ");
ref_server->getGroupManager()->cleanupAssignments(this->getClientDatabaseId()); ref_server->getGroupManager()->cleanupAssignments(this->getClientDatabaseId());
TIMING_STEP(timings, "grp cleanup"); 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 "); TIMING_STEP(timings, "grp apply ");
this->properties()[property::CLIENT_COUNTRY] = config::geo::countryFlag; this->properties()[property::CLIENT_COUNTRY] = config::geo::countryFlag;
@ -680,7 +680,6 @@ void SpeakingClient::processJoin() {
this->currentChannel = nullptr; this->currentChannel = nullptr;
{ {
/* enforce an update of these properties */ /* 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_INHERITED_CHANNEL_ID] = "0";
this->properties()[property::CLIENT_CHANNEL_GROUP_ID] = "0"; this->properties()[property::CLIENT_CHANNEL_GROUP_ID] = "0";
this->properties()[property::CLIENT_TALK_POWER] = "0"; this->properties()[property::CLIENT_TALK_POWER] = "0";

View File

@ -96,6 +96,7 @@ namespace ts {
bool lock_channel_tree bool lock_channel_tree
) override; ) override;
protected: protected:
void broadcast_text_message(const std::string &message); void broadcast_text_message(const std::string &message);

View File

@ -40,7 +40,7 @@ namespace ts {
sockaddr_in remote_address{}; sockaddr_in remote_address{};
std::mutex write_lock; std::mutex write_lock;
std::deque<pipes::buffer> write_buffer{}; std::deque<pipes::buffer> write_buffer{};
int file_descriptor; int file_descriptor{0};
struct event* event_read = nullptr; struct event* event_read = nullptr;
struct event* event_write = nullptr; struct event* event_write = nullptr;

View File

@ -128,7 +128,11 @@ void WebListManager::tick() {
_entry->current_request.reset(); _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();
}
} }
} }
} }