Adding a virtualserver channel limit

This commit is contained in:
WolverinDEV 2020-01-26 16:33:48 +01:00
parent d8337214f0
commit 87d607335e
2 changed files with 8 additions and 1 deletions

View File

@ -590,9 +590,10 @@ command_result ConnectedClient::handleCommandChannelCreate(Command &cmd) {
}
{
size_t created_tmp = 0, created_semi = 0, created_perm = 0;
size_t created_total = 0, created_tmp = 0, created_semi = 0, created_perm = 0;
auto own_cldbid = this->getClientDatabaseId();
for(const auto& channel : target_tree->channels()) {
created_total++;
if(channel->properties()[property::CHANNEL_CREATED_BY] == own_cldbid) {
if(channel->properties()[property::CHANNEL_FLAG_PERMANENT].as<bool>())
created_perm++;
@ -603,6 +604,8 @@ command_result ConnectedClient::handleCommandChannelCreate(Command &cmd) {
}
}
if(created_total >= this->server->properties()[property::VIRTUALSERVER_MAX_CHANNELS].as<uint64_t>())
return command_result{error::channel_limit_reached};
auto max_channels = this->calculate_permission(permission::i_client_max_channels, 0, false, permission_cache);
if(max_channels.has_value) {

View File

@ -92,6 +92,10 @@ command_result ConnectedClient::handleCommandServerEdit(Command &cmd) {
if (cmd["virtualserver_maxclients"].as<size_t>() > 1024)
return command_result{error::accounting_slot_limit_reached, "Do you really need more that 1024 slots?"};
} SERVEREDIT_CHK_PROP_CACHED("virtualserver_reserved_slots", permission::b_virtualserver_modify_reserved_slots, size_t) }
SERVEREDIT_CHK_PROP_CACHED("virtualserver_max_channels", permission::b_virtualserver_modify_maxchannels, size_t)
if(cmd["virtualserver_max_channels"].as<size_t>() > 8192)
return command_result{error::channel_protocol_limit_reached};
}
SERVEREDIT_CHK_PROP_CACHED("virtualserver_icon_id", permission::b_virtualserver_modify_icon_id, int64_t) }
SERVEREDIT_CHK_PROP_CACHED("virtualserver_channel_temp_delete_delay_default", permission::b_virtualserver_modify_channel_temp_delete_delay_default, ChannelId) }
SERVEREDIT_CHK_PROP_CACHED("virtualserver_codec_encryption_mode", permission::b_virtualserver_modify_codec_encryption_mode, int) }