From 316afd9f5649448798f1e15fbd2cac171623aaac Mon Sep 17 00:00:00 2001 From: WolverinDEV Date: Sat, 14 Sep 2019 12:06:45 +0200 Subject: [PATCH] Some fixes --- src/PermissionManager.cpp | 13 ++++++++++--- src/misc/strobf.h | 9 ++++----- src/protocol/Packet.h | 3 +++ 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/PermissionManager.cpp b/src/PermissionManager.cpp index c078f2d..a83037c 100644 --- a/src/PermissionManager.cpp +++ b/src/PermissionManager.cpp @@ -518,11 +518,21 @@ i_group_modify_power, b_virtualserver_token_add, b_virtualserver_token_use, b_virtualserver_token_delete, + + /* ban functions */ b_client_ban_create, b_client_ban_create_global, + + b_client_ban_list_global, + b_client_ban_list, + + b_client_ban_edit, + b_client_ban_edit_global, + b_client_ban_name, b_client_ban_ip, b_client_ban_hwid, + b_virtualserver_servergroup_list, b_virtualserver_servergroup_client_list, b_virtualserver_channelgroup_list, @@ -571,9 +581,6 @@ i_group_modify_power, b_channel_modify_temp_delete_delay, i_client_poke_power, - b_client_ban_list_global, - b_client_ban_list, - b_client_remoteaddress_view, i_client_music_play_power, diff --git a/src/misc/strobf.h b/src/misc/strobf.h index 11cfb90..6b03b20 100644 --- a/src/misc/strobf.h +++ b/src/misc/strobf.h @@ -146,7 +146,7 @@ namespace str_obf { std::uint64_t rng_seed = internal::time_seed() ^ internal::string_hash(_str_seed, 0) ^ line_number; std::uint64_t rng_base = rng_seed; - constexpr size_t key_length = generate_key_length(internal::time_seed() ^ (line_number << 37), max_size); + constexpr size_t key_length = generate_key_length(internal::time_seed() ^ (line_number << 37UL), max_size); std::array result{}; for(auto& it : result) it = (internal::rng32_next(rng_base, rng_seed) >> 16UL) & 0xFFUL; @@ -156,7 +156,7 @@ namespace str_obf { template struct decode_helper { const message& encoded; - std::array buffer{0}; + std::array buffer{0}; bool decoded = false; /* a trivial check which (if this only gets used once) the compiler could evaluate */ #ifndef _MSC_VER /* else if you call string_view() or string() it wound inline this method */ @@ -171,7 +171,6 @@ namespace str_obf { typename message::_char_t, typename message::_key_t >((typename message::_char_t*) &this->buffer[0], message::_size, this->encoded.key); - buffer[message::_size] = 0; /* append the null terminator at the end */ this->decoded = true; } @@ -179,10 +178,10 @@ namespace str_obf { } inline std::string_view string_view() noexcept { - return {this->c_str(), message::_size}; + return {this->c_str(), message::_size - 1}; } - inline std::string string() { return {this->c_str(), message::_size}; } + inline std::string string() { return {this->c_str(), message::_size - 1}; } //operator const char*() noexcept { return this->c_str(); } }; diff --git a/src/protocol/Packet.h b/src/protocol/Packet.h index 5728c64..29473ca 100644 --- a/src/protocol/Packet.h +++ b/src/protocol/Packet.h @@ -168,11 +168,14 @@ namespace ts { } inline std::unique_ptr>& getListener() { return this->listener; } + inline size_t length() const { return this->_buffer.length(); } inline const pipes::buffer_view mac() const { return this->_buffer.view(0, MAC_SIZE); } inline pipes::buffer mac() { return this->_buffer.range(0, MAC_SIZE); } + inline size_t mac_length() const { return MAC_SIZE; } inline const pipes::buffer_view header() const { return this->_buffer.view(MAC_SIZE, this->_header_length); } inline pipes::buffer header() { return this->_buffer.range(MAC_SIZE, this->_header_length); } + inline size_t header_length() const { return this->_header_length; } inline size_t data_length() const { return this->_buffer.length() - (MAC_SIZE + this->_header_length); } inline const pipes::buffer_view data() const { return this->_buffer.view(MAC_SIZE + this->_header_length); }