Updates for the 1.5.1 version

This commit is contained in:
WolverinDEV 2021-02-25 11:13:09 +01:00
parent dd8ea1c8d9
commit 7ff7d01cd3
8 changed files with 41 additions and 22 deletions

View File

@ -156,7 +156,9 @@ const std::vector<ErrorType> ts::availableErrors = {
{0x0D01, "server_connect_banned" , "connection failed, you are banned" },
{0x0D03, "ban_flooding" , "flood ban" },
{0x0F00, "token_invalid_id" , "invalid privilege key" },
define_error_description(token_invalid_id, "token unknown"),
define_error_description(token_expired, "token has been expired"),
define_error_description(token_use_limit_exceeded, "token has reached its use limit"),
{0x1000, "web_handshake_invalid" , "Invalid handshake" },
{0x1001, "web_handshake_unsupported" , "Handshake intention unsupported" },
@ -260,6 +262,7 @@ void command_result::build_error_response(ts::command_builder &builder, const st
break;
}
}
if(bulks->empty()) {
assert(false);
builder.put_unchecked(0, idKey, (uint32_t) error::ok);

View File

@ -163,7 +163,11 @@ namespace ts {
accounting_slot_limit_reached = 0xb01,
server_connect_banned = 0xd01,
ban_flooding = 0xd03,
token_invalid_id = 0xf00,
token_expired = 0xf10,
token_use_limit_exceeded = 0xf11,
web_handshake_invalid = 0x1000,
web_handshake_unsupported = 0x1001,
web_handshake_identity_unsupported = 0x1002,
@ -378,8 +382,9 @@ namespace ts {
explicit command_result_bulk(command_result&& result) { this->results.push_back(std::forward<command_result>(result)); }
~command_result_bulk() {
for(auto& result : this->results)
for(auto& result : this->results) {
result.release_data();
}
}
inline size_t length() const {
@ -399,7 +404,8 @@ namespace ts {
}
inline void set_result(size_t index, ts::command_result&& result) {
this->results[index].reset(std::forward<ts::command_result>(result));
auto& result_container = this->results[index];
result_container.reset(std::forward<ts::command_result>(result));
}
inline void emplace_result(permission::PermissionType permission) {

View File

@ -46,10 +46,11 @@ deque<std::shared_ptr<PermissionTypeEntry>> ts::permission::availablePermissions
make_shared<PermissionTypeEntry>(PermissionType::b_virtualserver_custom_search, PermissionGroup::vs_info, "b_virtualserver_custom_search", "Find custom fields"),
make_shared<PermissionTypeEntry>(PermissionType::b_virtualserver_start, PermissionGroup::vs_admin, "b_virtualserver_start", "Start own virtual server"),
make_shared<PermissionTypeEntry>(PermissionType::b_virtualserver_stop, PermissionGroup::vs_admin, "b_virtualserver_stop", "Stop own virtual server"),
make_shared<PermissionTypeEntry>(PermissionType::b_virtualserver_token_list, PermissionGroup::vs_admin, "b_virtualserver_token_list", "List privilege keys available"),
make_shared<PermissionTypeEntry>(PermissionType::b_virtualserver_token_add, PermissionGroup::vs_admin, "b_virtualserver_token_add", "Create new privilege keys"),
make_shared<PermissionTypeEntry>(PermissionType::b_virtualserver_token_list_all, PermissionGroup::vs_admin, "b_virtualserver_token_list_all", "Allows the client to list all tokens and not only his own"),
make_shared<PermissionTypeEntry>(PermissionType::b_virtualserver_token_edit_all, PermissionGroup::vs_admin, "b_virtualserver_token_edit_all", "Edit all generated tokens"),
make_shared<PermissionTypeEntry>(PermissionType::i_virtualserver_token_limit, PermissionGroup::vs_admin, "i_virtualserver_token_limit", "Max number of pending tokens a client could have"),
make_shared<PermissionTypeEntry>(PermissionType::b_virtualserver_token_use, PermissionGroup::vs_admin, "b_virtualserver_token_use", "Use a privilege keys to gain access to groups"),
make_shared<PermissionTypeEntry>(PermissionType::b_virtualserver_token_delete, PermissionGroup::vs_admin, "b_virtualserver_token_delete", "Delete a privilege key"),
make_shared<PermissionTypeEntry>(PermissionType::b_virtualserver_token_delete_all, PermissionGroup::vs_admin, "b_virtualserver_token_delete_all", "Allows the client to delete all tokens and not only the owned ones"),
make_shared<PermissionTypeEntry>(PermissionType::b_virtualserver_log_view, PermissionGroup::vs_admin, "b_virtualserver_log_view", "Retrieve virtual server log"),
make_shared<PermissionTypeEntry>(PermissionType::b_virtualserver_log_add, PermissionGroup::vs_admin, "b_virtualserver_log_add", "Write to virtual server log"),
make_shared<PermissionTypeEntry>(PermissionType::b_virtualserver_join_ignore_password, PermissionGroup::vs_admin, "b_virtualserver_join_ignore_password", "Join virtual server ignoring its password"),
@ -527,10 +528,10 @@ i_group_modify_power,
b_channel_delete_flag_force,
b_client_set_flag_talker,
b_channel_create_with_needed_talk_power,
b_virtualserver_token_list,
b_virtualserver_token_add,
b_virtualserver_token_list_all,
i_virtualserver_token_limit,
b_virtualserver_token_use,
b_virtualserver_token_delete,
b_virtualserver_token_delete_all,
b_video_screen,
b_video_camera,
@ -1442,9 +1443,11 @@ const std::vector<v2::PermissionDBUpdateEntry> v2::PermissionManager::flush_db_u
{
lock_guard use_lock(this->block_use_count_lock);
size_t block_count = 0;
for (auto &block_container : block_containers)
if (block_container)
for (auto &block_container : block_containers) {
if (block_container) {
block_count++;
}
}
result.reserve(block_count * PERMISSIONS_BULK_ENTRY_COUNT);
for(size_t block_index = 0; block_index < BULK_COUNT; block_index++) {

View File

@ -89,10 +89,11 @@ namespace ts {
/* virtual_server::administration */
b_virtualserver_start,
b_virtualserver_stop,
b_virtualserver_token_list,
b_virtualserver_token_add,
b_virtualserver_token_list_all,
i_virtualserver_token_limit,
b_virtualserver_token_edit_all,
b_virtualserver_token_use,
b_virtualserver_token_delete,
b_virtualserver_token_delete_all,
b_virtualserver_log_view,
b_virtualserver_log_add,
b_virtualserver_join_ignore_password,

View File

@ -194,13 +194,13 @@ namespace ts {
case 2:
/* we're already executing now but we need a new execute */
new_state = 3;
break;
return true;
default:
assert(false);
return false;
}
} while(!inner_->schedule_kind.compare_exchange_weak(current_state, new_state));
} while(!inner_->schedule_kind.compare_exchange_weak(current_state, new_state, std::memory_order_relaxed, std::memory_order_relaxed));
}
task_id task_id_;
@ -261,7 +261,7 @@ namespace ts {
assert(false);
return;
};
} while(!inner->schedule_kind.compare_exchange_weak(current_state, new_state));
} while(!inner->schedule_kind.compare_exchange_weak(current_state, new_state, std::memory_order_relaxed, std::memory_order_relaxed));
if(new_state == 1) {
/* a reschedule was requested */

View File

@ -337,8 +337,10 @@ namespace ts {
required_size += entry.size() + 1;
}
result.append(this->identifier_);
result.push_back(' ');
if(!this->identifier_.empty()) {
result.append(this->identifier_);
result.push_back(' ');
}
for(auto it = this->bulks.begin(); it != this->bulks.end(); it++) {
if(it->empty() && !with_empty) {
@ -364,8 +366,9 @@ namespace ts {
inline void reserve_bulks(size_t count) { this->bulks.reserve(count); }
[[nodiscard]] inline command_builder_bulk bulk(size_t index) {
while(this->bulks.size() <= index)
while(this->bulks.size() <= index) {
this->bulks.emplace_back("").reserve(expected_bulk_size);
}
return command_builder_bulk{this->flag_changed, this->bulks[index]};
}
@ -396,8 +399,9 @@ namespace ts {
}
inline void set_bulk(size_t index, standalone_command_builder_bulk&& bulk) {
while(this->bulks.size() <= index)
while(this->bulks.size() <= index) {
this->bulks.emplace_back("").reserve(expected_bulk_size);
}
this->bulks[index] = std::move(bulk.buffer());
this->flag_changed = true;
}

View File

@ -8,7 +8,7 @@ using namespace std;
using namespace std::chrono;
namespace sql {
result result::success = result("", 0, "success");
result result::success = result("", 0, -1, "success");
sql::command model::command() { return ::sql::command(*this); }
sql::model model::copy() { return sql::model(this->_data); }
model::model(const std::shared_ptr<CommandData>& data) : command_base(data->handle->copyCommandData(data)) {}

View File

@ -35,6 +35,8 @@ namespace sql {
static result success;
result() : result{success} { }
result(int code, std::string msg)
: code_{code}, msg_{std::move(msg)}, sql_{""}, last_insert_rowid_{-1} { }
result(std::string query, int code, int64_t last_insert_rowid, std::string msg)
: code_{code}, msg_{std::move(msg)}, sql_{std::move(query)}, last_insert_rowid_{last_insert_rowid} { }