From 5245e4ffc14a91051623731ab1f0b33024ba8fa7 Mon Sep 17 00:00:00 2001 From: WolverinDEV Date: Wed, 13 May 2020 12:22:12 +0200 Subject: [PATCH 1/4] Fixed stats overflow --- server/src/client/command_handler/server.cpp | 16 ++++++++-------- server/src/client/query/QueryClientCommands.cpp | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/server/src/client/command_handler/server.cpp b/server/src/client/command_handler/server.cpp index 7401b05..8878187 100644 --- a/server/src/client/command_handler/server.cpp +++ b/server/src/client/command_handler/server.cpp @@ -267,15 +267,15 @@ command_result ConnectedClient::handleCommandServerRequestConnectionInfo(Command first_bulk.put_unchecked("connection_filetransfer_bytes_sent_month", this->server->properties()[property::VIRTUALSERVER_MONTH_BYTES_DOWNLOADED].as()); first_bulk.put_unchecked("connection_filetransfer_bytes_received_month", this->server->properties()[property::VIRTUALSERVER_MONTH_BYTES_UPLOADED].as()); - first_bulk.put_unchecked(property::CONNECTION_PACKETS_SENT_TOTAL, std::accumulate(total_stats.connection_packets_sent.begin(), total_stats.connection_packets_sent.end(), 0U)); - first_bulk.put_unchecked(property::CONNECTION_BYTES_SENT_TOTAL, std::accumulate(total_stats.connection_bytes_sent.begin(), total_stats.connection_bytes_sent.end(), 0U)); - first_bulk.put_unchecked(property::CONNECTION_PACKETS_RECEIVED_TOTAL, std::accumulate(total_stats.connection_packets_received.begin(), total_stats.connection_packets_received.end(), 0U)); - first_bulk.put_unchecked(property::CONNECTION_BYTES_RECEIVED_TOTAL, std::accumulate(total_stats.connection_bytes_received.begin(), total_stats.connection_bytes_received.end(), 0U)); + first_bulk.put_unchecked(property::CONNECTION_PACKETS_SENT_TOTAL, std::accumulate(total_stats.connection_packets_sent.begin(), total_stats.connection_packets_sent.end(), (size_t) 0U)); + first_bulk.put_unchecked(property::CONNECTION_BYTES_SENT_TOTAL, std::accumulate(total_stats.connection_bytes_sent.begin(), total_stats.connection_bytes_sent.end(), (size_t) 0U)); + first_bulk.put_unchecked(property::CONNECTION_PACKETS_RECEIVED_TOTAL, std::accumulate(total_stats.connection_packets_received.begin(), total_stats.connection_packets_received.end(), (size_t) 0U)); + first_bulk.put_unchecked(property::CONNECTION_BYTES_RECEIVED_TOTAL, std::accumulate(total_stats.connection_bytes_received.begin(), total_stats.connection_bytes_received.end(), (size_t) 0U)); - first_bulk.put_unchecked(property::CONNECTION_BANDWIDTH_SENT_LAST_SECOND_TOTAL, std::accumulate(second_report.connection_bytes_sent.begin(), second_report.connection_bytes_sent.end(), 0U)); - first_bulk.put_unchecked(property::CONNECTION_BANDWIDTH_SENT_LAST_MINUTE_TOTAL, std::accumulate(minute_report.connection_bytes_sent.begin(), minute_report.connection_bytes_sent.end(), 0U)); - first_bulk.put_unchecked(property::CONNECTION_BANDWIDTH_RECEIVED_LAST_SECOND_TOTAL, std::accumulate(second_report.connection_bytes_received.begin(), second_report.connection_bytes_received.end(), 0U)); - first_bulk.put_unchecked(property::CONNECTION_BANDWIDTH_RECEIVED_LAST_MINUTE_TOTAL, std::accumulate(minute_report.connection_bytes_received.begin(), minute_report.connection_bytes_received.end(), 0U)); + first_bulk.put_unchecked(property::CONNECTION_BANDWIDTH_SENT_LAST_SECOND_TOTAL, std::accumulate(second_report.connection_bytes_sent.begin(), second_report.connection_bytes_sent.end(), (size_t) 0U)); + first_bulk.put_unchecked(property::CONNECTION_BANDWIDTH_SENT_LAST_MINUTE_TOTAL, std::accumulate(minute_report.connection_bytes_sent.begin(), minute_report.connection_bytes_sent.end(), (size_t) 0U)); + first_bulk.put_unchecked(property::CONNECTION_BANDWIDTH_RECEIVED_LAST_SECOND_TOTAL, std::accumulate(second_report.connection_bytes_received.begin(), second_report.connection_bytes_received.end(), (size_t) 0U)); + first_bulk.put_unchecked(property::CONNECTION_BANDWIDTH_RECEIVED_LAST_MINUTE_TOTAL, std::accumulate(minute_report.connection_bytes_received.begin(), minute_report.connection_bytes_received.end(), (size_t) 0U)); first_bulk.put_unchecked(property::CONNECTION_CONNECTED_TIME, this->server->properties()[property::VIRTUALSERVER_UPTIME].as()); first_bulk.put_unchecked(property::CONNECTION_PACKETLOSS_TOTAL, network_report.average_loss); diff --git a/server/src/client/query/QueryClientCommands.cpp b/server/src/client/query/QueryClientCommands.cpp index 4749c8d..9fd5ba8 100644 --- a/server/src/client/query/QueryClientCommands.cpp +++ b/server/src/client/query/QueryClientCommands.cpp @@ -769,17 +769,17 @@ command_result QueryClient::handleCommandHostInfo(Command &) { auto total_stats = serverInstance->getStatistics()->total_stats(); - res["connection_packets_sent_total"] = std::accumulate(total_stats.connection_packets_sent.begin(), total_stats.connection_packets_sent.end(), 0U); - res["connection_bytes_sent_total"] = std::accumulate(total_stats.connection_bytes_sent.begin(), total_stats.connection_bytes_sent.end(), 0U); - res["connection_packets_received_total"] = std::accumulate(total_stats.connection_packets_received.begin(), total_stats.connection_packets_received.end(), 0U); - res["connection_bytes_received_total"] = std::accumulate(total_stats.connection_bytes_received.begin(), total_stats.connection_bytes_received.end(), 0U); + res["connection_packets_sent_total"] = std::accumulate(total_stats.connection_packets_sent.begin(), total_stats.connection_packets_sent.end(), (size_t) 0U); + res["connection_bytes_sent_total"] = std::accumulate(total_stats.connection_bytes_sent.begin(), total_stats.connection_bytes_sent.end(), (size_t) 0U); + res["connection_packets_received_total"] = std::accumulate(total_stats.connection_packets_received.begin(), total_stats.connection_packets_received.end(), (size_t) 0U); + res["connection_bytes_received_total"] = std::accumulate(total_stats.connection_bytes_received.begin(), total_stats.connection_bytes_received.end(), (size_t) 0U); auto report_second = serverInstance->getStatistics()->second_stats(); auto report_minute = serverInstance->getStatistics()->minute_stats(); - res["connection_bandwidth_sent_last_second_total"] = std::accumulate(report_second.connection_bytes_sent.begin(), report_second.connection_bytes_sent.end(), 0U); - res["connection_bandwidth_sent_last_minute_total"] = std::accumulate(report_minute.connection_bytes_sent.begin(), report_minute.connection_bytes_sent.end(), 0U); - res["connection_bandwidth_received_last_second_total"] = std::accumulate(report_second.connection_bytes_received.begin(), report_second.connection_bytes_received.end(), 0U); - res["connection_bandwidth_received_last_minute_total"] = std::accumulate(report_minute.connection_bytes_received.begin(), report_minute.connection_bytes_received.end(), 0U); + res["connection_bandwidth_sent_last_second_total"] = std::accumulate(report_second.connection_bytes_sent.begin(), report_second.connection_bytes_sent.end(), (size_t) 0U); + res["connection_bandwidth_sent_last_minute_total"] = std::accumulate(report_minute.connection_bytes_sent.begin(), report_minute.connection_bytes_sent.end(), (size_t) 0U); + res["connection_bandwidth_received_last_second_total"] = std::accumulate(report_second.connection_bytes_received.begin(), report_second.connection_bytes_received.end(), (size_t) 0U); + res["connection_bandwidth_received_last_minute_total"] = std::accumulate(report_minute.connection_bytes_received.begin(), report_minute.connection_bytes_received.end(), (size_t) 0U); res["connection_filetransfer_bandwidth_sent"] = report_minute.file_bytes_sent; From 14870efc115964524b263499d33c44a0c74aff15 Mon Sep 17 00:00:00 2001 From: WolverinDEV Date: Thu, 14 May 2020 15:18:39 +0200 Subject: [PATCH 2/4] Fixed permission assignments --- git-teaspeak | 2 +- server/src/client/command_handler/bulk_parsers.h | 8 +++++--- shared | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/git-teaspeak b/git-teaspeak index a8a0aab..be826cc 160000 --- a/git-teaspeak +++ b/git-teaspeak @@ -1 +1 @@ -Subproject commit a8a0aabd7fca05b950de9f781a3cd6ba5b799f79 +Subproject commit be826ccb507a84d97c9c07397b05a8fe731f7ce5 diff --git a/server/src/client/command_handler/bulk_parsers.h b/server/src/client/command_handler/bulk_parsers.h index 4b7f76b..b25c8ec 100644 --- a/server/src/client/command_handler/bulk_parsers.h +++ b/server/src/client/command_handler/bulk_parsers.h @@ -78,13 +78,15 @@ namespace ts::command::bulk_parser { inline void apply_to(const std::shared_ptr& manager, permission::v2::PermissionUpdateType mode) const { if(this->is_grant_permission()) { - manager->set_permission(this->permission_type(), { this->value(), true }, permission::v2::PermissionUpdateType::do_nothing, mode); + manager->set_permission(this->permission_type(), { 0, this->value() }, permission::v2::PermissionUpdateType::do_nothing, mode); } else { manager->set_permission( this->permission_type(), - { this->value(), true }, + { this->value(), 0 }, mode, - permission::v2::PermissionUpdateType::do_nothing + permission::v2::PermissionUpdateType::do_nothing, + this->flag_skip(), + this->flag_negated() ); } } diff --git a/shared b/shared index a4febf7..f404d5e 160000 --- a/shared +++ b/shared @@ -1 +1 @@ -Subproject commit a4febf7b5af191d41c566292958c55155128f16f +Subproject commit f404d5e1fa5ed1cfbe3ef9a97c0e81c1fba943ff From c7f989da8bf28cfda663a161f13e17738041ac38 Mon Sep 17 00:00:00 2001 From: WolverinDEV Date: Mon, 18 May 2020 17:30:44 +0200 Subject: [PATCH 3/4] Fixed server statistics --- server/src/client/query/QueryClientCommands.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/server/src/client/query/QueryClientCommands.cpp b/server/src/client/query/QueryClientCommands.cpp index 9fd5ba8..58b125f 100644 --- a/server/src/client/query/QueryClientCommands.cpp +++ b/server/src/client/query/QueryClientCommands.cpp @@ -409,10 +409,10 @@ command_result QueryClient::handleCommandServerInfo(Command &) { auto total_stats = this->server->getServerStatistics()->total_stats(); auto report_second = this->server->serverStatistics->second_stats(); auto report_minute = this->server->serverStatistics->minute_stats(); - cmd["connection_bandwidth_sent_last_second_total"] = std::accumulate(report_second.connection_bytes_sent.begin(), report_second.connection_bytes_sent.end(), 0U); - cmd["connection_bandwidth_sent_last_minute_total"] = std::accumulate(report_minute.connection_bytes_sent.begin(), report_minute.connection_bytes_sent.end(), 0U); - cmd["connection_bandwidth_received_last_second_total"] = std::accumulate(report_second.connection_bytes_received.begin(), report_second.connection_bytes_received.end(), 0U); - cmd["connection_bandwidth_received_last_minute_total"] = std::accumulate(report_minute.connection_bytes_received.begin(), report_minute.connection_bytes_received.end(), 0U); + cmd["connection_bandwidth_sent_last_second_total"] = std::accumulate(report_second.connection_bytes_sent.begin(), report_second.connection_bytes_sent.end(), (size_t) 0U); + cmd["connection_bandwidth_sent_last_minute_total"] = std::accumulate(report_minute.connection_bytes_sent.begin(), report_minute.connection_bytes_sent.end(), (size_t) 0U); + cmd["connection_bandwidth_received_last_second_total"] = std::accumulate(report_second.connection_bytes_received.begin(), report_second.connection_bytes_received.end(), (size_t) 0U); + cmd["connection_bandwidth_received_last_minute_total"] = std::accumulate(report_minute.connection_bytes_received.begin(), report_minute.connection_bytes_received.end(), (size_t) 0U); cmd["connection_filetransfer_bandwidth_sent"] = report_minute.file_bytes_sent; cmd["connection_filetransfer_bandwidth_received"] = report_minute.file_bytes_received; @@ -434,10 +434,10 @@ command_result QueryClient::handleCommandServerInfo(Command &) { cmd["connection_packets_received_control"] = total_stats.connection_packets_received[stats::ConnectionStatistics::category::COMMAND]; cmd["connection_bytes_received_control"] = total_stats.connection_bytes_received[stats::ConnectionStatistics::category::COMMAND]; - cmd["connection_packets_sent_total"] = std::accumulate(total_stats.connection_packets_sent.begin(), total_stats.connection_packets_sent.end(), 0U); - cmd["connection_bytes_sent_total"] = std::accumulate(total_stats.connection_bytes_sent.begin(), total_stats.connection_bytes_sent.end(), 0U); - cmd["connection_packets_received_total"] = std::accumulate(total_stats.connection_packets_received.begin(), total_stats.connection_packets_received.end(), 0U); - cmd["connection_bytes_received_total"] = std::accumulate(total_stats.connection_bytes_received.begin(), total_stats.connection_bytes_received.end(), 0U); + cmd["connection_packets_sent_total"] = std::accumulate(total_stats.connection_packets_sent.begin(), total_stats.connection_packets_sent.end(), (size_t) 0U); + cmd["connection_bytes_sent_total"] = std::accumulate(total_stats.connection_bytes_sent.begin(), total_stats.connection_bytes_sent.end(), (size_t) 0U); + cmd["connection_packets_received_total"] = std::accumulate(total_stats.connection_packets_received.begin(), total_stats.connection_packets_received.end(), (size_t) 0U); + cmd["connection_bytes_received_total"] = std::accumulate(total_stats.connection_bytes_received.begin(), total_stats.connection_bytes_received.end(), (size_t) 0U); } else { cmd["connection_bandwidth_sent_last_second_total"] = "0"; cmd["connection_bandwidth_sent_last_minute_total"] = "0"; From f7924d29dfa80b560497c74ebd07c053445c2b79 Mon Sep 17 00:00:00 2001 From: WolverinDEV Date: Tue, 19 May 2020 09:51:54 +0200 Subject: [PATCH 4/4] Fixed YatQa rror --- server/src/client/query/QueryClientCommands.cpp | 8 +++++--- server/src/manager/SqlDataManager.h | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/server/src/client/query/QueryClientCommands.cpp b/server/src/client/query/QueryClientCommands.cpp index 58b125f..9aff148 100644 --- a/server/src/client/query/QueryClientCommands.cpp +++ b/server/src/client/query/QueryClientCommands.cpp @@ -486,11 +486,13 @@ command_result QueryClient::handleCommandChannelList(Command& cmd) { command_builder result{"", 1024, entries.size()}; for(const auto& channel : entries){ if(!channel) continue; + + const auto channel_clients = this->server ? this->server->getClientsByChannel(channel).size() : 0; result.put_unchecked(index, "cid", channel->channelId()); result.put_unchecked(index, "pid", channel->properties()[property::CHANNEL_PID].as()); result.put_unchecked(index, "channel_name", channel->name()); result.put_unchecked(index, "channel_order", channel->channelOrder()); - result.put_unchecked(index, "total_clients", this->server ? this->server->getClientsByChannel(channel).size() : 0); + result.put_unchecked(index, "total_clients", channel_clients); /* result.put_unchecked(index, "channel_needed_subscribe_power", channel->permissions()->getPermissionValue(permission::i_channel_needed_subscribe_power, channel, 0)); */ if(cmd.hasParm("flags")){ @@ -522,8 +524,8 @@ command_result QueryClient::handleCommandChannelList(Command& cmd) { if(cmd.hasParm("topic")) { result.put_unchecked(index, "channel_topic", channel->properties()[property::CHANNEL_TOPIC].as()); } - if(cmd.hasParm("times")){ - result.put_unchecked(index, "seconds_empty", channel->emptySince()); + if(cmd.hasParm("times") || cmd.hasParm("secondsempty")){ + result.put_unchecked(index, "seconds_empty", channel_clients == 0 ? channel->emptySince() : 0); } index++; } diff --git a/server/src/manager/SqlDataManager.h b/server/src/manager/SqlDataManager.h index 6ff625e..80544e6 100644 --- a/server/src/manager/SqlDataManager.h +++ b/server/src/manager/SqlDataManager.h @@ -10,7 +10,7 @@ namespace ts { virtual ~SqlDataManager(); [[nodiscard]] inline int get_database_version() const { return this->_database_version; } - [[nodiscard]] inline int get_permissions_version() const { return this->_database_version; } + [[nodiscard]] inline int get_permissions_version() const { return this->_permissions_version; } bool initialize(std::string&); void finalize();