Some updates

This commit is contained in:
WolverinDEV 2020-03-31 22:01:46 +02:00
parent 064d54eac5
commit 4965c4d3d0
6 changed files with 11 additions and 14 deletions

View File

@ -268,7 +268,7 @@ if(BUILD_TESTS)
target_link_libraries(RingTest ${TEST_LIBRARIES})
if(NOT WIN32)
add_executable(CommandTest ${SOURCE_FILES} ${HEADER_FILES} test/CommandTest.cpp src/log/LogSinks.cpp src/log/LogSinks.h ../server/MySQLLibSSLFix.c)
add_executable(CommandTest ${SOURCE_FILES} ${HEADER_FILES} test/CommandTest.cpp src/log/LogSinks.cpp src/log/LogSinks.h)
target_link_libraries(CommandTest ${TEST_LIBRARIES})
add_executable(WebsocketTest ${SOURCE_FILES} ${HEADER_FILES} test/WSSTest.cpp src/log/LogSinks.cpp src/log/LogSinks.h)
@ -299,7 +299,7 @@ if(BUILD_TESTS)
add_executable(PermissionTest test/PermissionTest.cpp ${SOURCE_FILES})
target_link_libraries(PermissionTest ${TEST_LIBRARIES})
add_executable(GenerationTest test/generationTest.cpp ${SOURCE_FILES} ../server/MySQLLibSSLFix.c)
add_executable(GenerationTest test/generationTest.cpp src/protocol/generation.cpp)
target_link_libraries(GenerationTest ${TEST_LIBRARIES})
add_executable(RW-Lock-Test test/rw_lock.cpp src/lock/rw_mutex.cpp)

View File

@ -330,7 +330,8 @@ deque<std::shared_ptr<PermissionTypeEntry>> ts::permission::availablePermissions
make_shared<PermissionTypeEntry>(PermissionType::b_client_delete_dbproperties, PermissionGroup::client_modify, "b_client_delete_dbproperties", "Delete a clients properties in the sql"),
make_shared<PermissionTypeEntry>(PermissionType::b_client_create_modify_serverquery_login, PermissionGroup::client_modify, "b_client_create_modify_serverquery_login", "Create or modify own ServerQuery account"),
make_shared<PermissionTypeEntry>(PermissionType::b_client_query_create, PermissionGroup::client_modify, "b_client_query_create", "Create your own ServerQuery account"),
make_shared<PermissionTypeEntry>(PermissionType::b_client_query_create, PermissionGroup::client_modify, "b_client_query_create", "Create a ServerQuery account for any user"),
make_shared<PermissionTypeEntry>(PermissionType::b_client_query_create_own, PermissionGroup::client_modify, "b_client_query_create_own", "Create your own ServerQuery account"),
make_shared<PermissionTypeEntry>(PermissionType::b_client_query_list, PermissionGroup::client_modify, "b_client_query_list", "List all ServerQuery accounts"),
make_shared<PermissionTypeEntry>(PermissionType::b_client_query_list_own, PermissionGroup::client_modify, "b_client_query_list_own", "List all own ServerQuery accounts"),
make_shared<PermissionTypeEntry>(PermissionType::b_client_query_rename, PermissionGroup::client_modify, "b_client_query_rename", "Rename a ServerQuery account"),

View File

@ -438,6 +438,7 @@ namespace ts {
b_client_delete_dbproperties,
b_client_create_modify_serverquery_login,
b_client_query_create,
b_client_query_create_own,
b_client_query_list,
b_client_query_list_own,
b_client_query_rename,

View File

@ -5,7 +5,7 @@
std::string base64::decode(const char* input, size_t size) {
auto out = new unsigned char[size];
if(base64_strict_decode((unsigned char*) input, (unsigned long) size, out, (unsigned long*) &size) != CRYPT_OK){
std::cerr << "Invalid base 64 string '" << input << "'" << std::endl;
//std::cerr << "Invalid base 64 string '" << input << "'" << std::endl;
return "";
}
std::string ret((char*) out, size);
@ -17,7 +17,7 @@ std::string base64::encode(const char* input, const unsigned long inputSize) {
auto outlen = static_cast<unsigned long>(inputSize + (inputSize / 3.0) + 16);
auto outbuf = new unsigned char[outlen]; //Reserve output memory
if(base64_encode((unsigned char*) input, inputSize, outbuf, &outlen) != CRYPT_OK){
std::cerr << "Invalid input '" << input << "'" << std::endl;
//std::cerr << "Invalid input '" << input << "'" << std::endl;
return "";
}
std::string ret((char*) outbuf, outlen);

View File

@ -8,8 +8,8 @@ namespace ts::protocol {
generation_estimator();
void reset();
uint16_t visit_packet(uint16_t /* packet id */);
uint16_t generation() const;
[[nodiscard]] uint16_t visit_packet(uint16_t /* packet id */);
[[nodiscard]] uint16_t generation() const;
void set_last_state(uint16_t last_packet, uint16_t generation) {
this->last_packet_id = last_packet;

View File

@ -75,22 +75,17 @@ int main() {
test_vector("25 loss", generate_test_vector(0x3000, 25));
test_vector("50 loss", generate_test_vector(0x3000, 50));
test_vector("80 loss", generate_test_vector(0x3000, 80));
test_vector("99 loss", generate_test_vector(0x3000, 99));
}
{
auto base = generate_test_vector(0x3000, 0);
test_vector("swap 0:4", swap_elements(base, 0, 4));
test_vector("swap 30:20", swap_elements(base, 30, 20));
test_vector("swap 30:1000", swap_elements(base, 30, 200));
test_vector("swap 80:1000", swap_elements(base, 80, 200));
}
if(false) {
test_vector("10 loss", generate_test_vector(0x3000, 10));
test_vector("25 loss", generate_test_vector(0x3000, 25));
test_vector("50 loss", generate_test_vector(0x3000, 50));
test_vector("80 loss", generate_test_vector(0x3000, 80));
}
gen.set_last_state(0, 0);
test_vector<6>(gen, {0, 1, 2, 4, 3, 5}, {0, 0, 0, 0, 0, 0});