# Conflicts:
#	src/Error.h
This commit is contained in:
WolverinDEV 2019-10-13 20:04:46 +02:00
commit 228bde912a
21 changed files with 59 additions and 37 deletions

View File

@ -1,4 +1,4 @@
1
success
bd69955e34daa3cc0e923a3789ff627451991441
07 Jul 2019 19:14:36
cb73d9df3258eaf59e4799c9e54d5f865e891734
22 Sep 2019 13:38:56

View File

@ -5,6 +5,11 @@ set(CMAKE_CXX_STANDARD 17)
if(NOT WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -Wall -Wno-reorder -Wno-sign-compare -fpermissive -ftemplate-depth=1000 ${MEMORY_DEBUG_FLAGS}")
set(CMAKE_INCLUDE_CURRENT_DIR ON)
else()
#For Windows
add_definitions(-D_SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING)
add_compile_options(/wd4996) #'std::result_of_t': warning STL4014: std::result_of and std::result_of_t are deprecated in C++17.
endif()
if(CMAKE_PLATFORM_INCLUDE AND NOT CMAKE_PLATFORM_INCLUDE STREQUAL "")

View File

@ -117,12 +117,12 @@ bool BasicChannel::passwordMatch(std::string password, bool hashed) {
return this->properties()[property::CHANNEL_PASSWORD].as<string>() == password;
}
int BasicChannel::emptySince() {
int64_t BasicChannel::emptySince() {
if (!properties().hasProperty(property::CHANNEL_LAST_LEFT))
return 0;
time_point<system_clock> lastLeft = time_point<system_clock>() + milliseconds(properties()[property::CHANNEL_LAST_LEFT].as<uint64_t>());
return duration_cast<seconds>(system_clock::now() - lastLeft).count();
return (int64_t) duration_cast<seconds>(system_clock::now() - lastLeft).count();
}
void BasicChannel::setLinkedHandle(const std::weak_ptr<TreeView::LinkedTreeEntry> &ptr) {

View File

@ -52,7 +52,7 @@ namespace ts {
bool passwordMatch(std::string password, bool hashed = false);
bool defaultChannel() { return (*this->_properties)[property::CHANNEL_FLAG_DEFAULT]; }
int emptySince();
int64_t emptySince();
inline std::chrono::system_clock::time_point createdTimestamp() {
return std::chrono::system_clock::time_point() + std::chrono::milliseconds(this->properties()[property::CHANNEL_CREATED_AT].as<int64_t>());

View File

@ -1,3 +1,5 @@
#include <utility>
#pragma once
#include <cassert>
@ -261,9 +263,8 @@ namespace ts {
static ErrorType VSError;
static ErrorType DBEmpty;
ErrorType(const uint16_t errorId, const std::string &name, const std::string &message) : errorId(errorId), name(name), message(message) {}
ErrorType(const ErrorType& ref) : errorId(ref.errorId), name(ref.name), message(ref.message) {}
ErrorType(const uint16_t errorId, std::string name, std::string message) : errorId(errorId), name(std::move(name)), message(std::move(message)) {}
ErrorType(const ErrorType& ref) = default;
ErrorType(ErrorType&& ref) : errorId(ref.errorId), name(std::move(ref.name)), message(std::move(ref.message)) {}
uint16_t errorId;

View File

@ -263,7 +263,7 @@ void LicenseChain::print() {
auto key = this->generatePublicKey();
cout << "Public key: " << endl;
hexDump((char*) key.data(), key.length(), key.length(), key.length(), [](string message) { cout << message << endl; });
hexDump((char*) key.data(), (int) key.length(), (int) key.length(), (int) key.length(), [](string message) { cout << message << endl; });
}
std::string LicenseChain::exportChain() {

View File

@ -637,7 +637,6 @@ namespace ts {
}
Permission(Permission &) = delete;
Permission(const Permission &) = delete;
Permission() = delete;

View File

@ -20,7 +20,7 @@ bool Properties::has(property::PropertyType type, int index) {
if(!*it) continue;
if(it->get()->type != type) continue;
index -= it->get()->offset;
index -= (int) it->get()->offset;
if(index < 0) return false;
return index < it->get()->length;
}
@ -33,7 +33,7 @@ PropertyWrapper Properties::find(property::PropertyType type, int index) {
if(bulk->type != type)
continue;
index -= bulk->offset;
index -= (int) bulk->offset;
if(index < 0)
break;
@ -112,7 +112,7 @@ bool Properties::register_property_type(ts::property::PropertyType type, size_t
new (&property.casted_value) any();
new (&property.value_lock) spin_lock();
new (&property.value) string();
new (&property.description) shared_ptr<property::PropertyDescription>(property::impl::info(type, offset + index));
new (&property.description) shared_ptr<property::PropertyDescription>(property::impl::info(type, (int) (offset + index)));
property.flag_modified = false;
property.flag_db_reference = false;

View File

@ -613,13 +613,19 @@ namespace ts {
bool flag_modified;
};
#ifdef WIN32
#pragma warning( push )
#pragma warning( disable : 4200 )
#endif
struct PropertyBundle {
property::PropertyType type;
size_t length;
size_t offset;
PropertyData properties[0];
};
#ifdef WIN32
#pragma warning( pop )
#endif
template <typename T>
struct PropertyAccess {

View File

@ -127,10 +127,10 @@ DEFINE_VARIABLE_TRANSFORM(char*, VARTYPE_TEXT, std::string((const char*) in), (c
DEFINE_VARIABLE_TRANSFORM(const char*, VARTYPE_TEXT, std::string((const char*) in), in.value().c_str());
DEFINE_VARIABLE_TRANSFORM(int8_t, VARTYPE_INT, std::to_string(in), std::stoi(in.value()));
DEFINE_VARIABLE_TRANSFORM(uint8_t, VARTYPE_INT, std::to_string(in), std::stoul(in.value()));
DEFINE_VARIABLE_TRANSFORM(uint8_t, VARTYPE_INT, std::to_string(in), (uint8_t) std::stoul(in.value()));
DEFINE_VARIABLE_TRANSFORM(int16_t, VARTYPE_INT, std::to_string(in), std::stoi(in.value()));
DEFINE_VARIABLE_TRANSFORM(uint16_t, VARTYPE_INT, std::to_string(in), std::stoul(in.value()));
DEFINE_VARIABLE_TRANSFORM(uint16_t, VARTYPE_INT, std::to_string(in), (uint16_t) std::stoul(in.value()));
DEFINE_VARIABLE_TRANSFORM(int32_t, VARTYPE_INT, std::to_string(in), std::stoi(in.value()));
DEFINE_VARIABLE_TRANSFORM(uint32_t, VARTYPE_INT, std::to_string(in), std::stoul(in.value()));

View File

@ -16,7 +16,7 @@ namespace fs = std::experimental::filesystem;
#define ASYNC_LOG
namespace logger {
recursive_mutex loggerLock;
map<int, std::shared_ptr<spdlog::logger>> loggers;
map<size_t, std::shared_ptr<spdlog::logger>> loggers;
shared_ptr<LoggerConfig> logConfig;
shared_ptr<::logger::TerminalSink> terminalSink;
shared_ptr<::logger::CostumeFormatter> costumeFormatter;
@ -25,7 +25,7 @@ namespace logger {
if(!::logger::currentConfig())
return nullptr;
int group = 0;
size_t group = 0;
if(::logger::currentConfig()->vs_group_size > 0 && serverId > 0)
group = serverId / ::logger::currentConfig()->vs_group_size;
else group = -1;
@ -46,10 +46,15 @@ namespace logger {
strvar::FunctionValue("time", (strvar::FunctionValue::FValueFNEasy) [](std::deque<std::string> value) -> std::string {
auto pattern = !value.empty() ? value[0] : "%Y-%m-%d_%H:%M:%S";
tm* tm_info;
auto secs = duration_cast<seconds>(logConfig->timestamp.time_since_epoch()).count();
tm* tm_info;
#ifdef WIN32
tm _tm_info{};
localtime_s(&_tm_info, &secs);
tm_info = &_tm_info;
#else
tm_info = localtime((time_t*) &secs);
#endif
char timeBuffer[1024];
if(strftime(timeBuffer, 1024, pattern.c_str(), tm_info) == 0) {
return string("string is longer than the buffer");

View File

@ -4,7 +4,7 @@
std::string base64::decode(const char* input, size_t size) {
auto out = new unsigned char[size];
if(base64_strict_decode((unsigned char*) input, size, out, (unsigned long*) &size) != CRYPT_OK){
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;
return "";
}

View File

@ -17,7 +17,7 @@ namespace base64 {
* @param input The input string to Base64-encode
* @return A Base64-encoded version of the encoded string
*/
inline std::string encode(const std::string& input) { return encode(input.c_str(), input.size()); }
inline std::string encode(const std::string& input) { return encode(input.c_str(), (unsigned long) input.size()); }
/**
@ -48,4 +48,4 @@ namespace base64 {
}
}
inline std::string base64_encode(const char* input, const unsigned long inputSize) { return base64::encode(input, inputSize); }
inline std::string base64_encode(const std::string& input) { return base64::encode(input.c_str(), input.size()); }
inline std::string base64_encode(const std::string& input) { return base64::encode(input.c_str(), (unsigned long) input.size()); }

View File

@ -2,12 +2,12 @@
#ifdef NO_OPEN_SSL
#include <tomcrypt.h>
#define DECLARE_DIGEST(name, digestLength) \
void digest::tomcrypt::name(const char* input, size_t length, uint8_t* result) { \
#define DECLARE_DIGEST(name, digestLength) \
void digest::tomcrypt::name(const char* input, size_t length, uint8_t* result) { \
hash_state hash{}; \
\
name ##_init(&hash); \
name ##_process(&hash, (uint8_t*) input, length); \
name ##_process(&hash, (uint8_t*) input, (unsigned long) length); \
name ##_done(&hash, result); \
}

View File

@ -26,7 +26,6 @@ namespace ts {
delete this->data;
}
PacketTypeInfo::PacketTypeInfo(PacketTypeInfo &red) : data(red.data) { }
PacketTypeInfo::PacketTypeInfo(const PacketTypeInfo &red) : data(red.data) { }
std::map<int, PacketTypeInfo> PacketTypeInfo::types;
@ -65,13 +64,13 @@ namespace ts {
}
BasicPacket::BasicPacket(size_t header_length, size_t data_length) {
this->_header_length = header_length;
this->_header_length = (uint8_t) header_length;
this->_buffer = pipes::buffer(MAC_SIZE + this->_header_length + data_length);
memset(this->_buffer.data_ptr(), 0, this->_buffer.length());
}
BasicPacket::BasicPacket(size_t header_length, const pipes::buffer &buffer) {
this->_header_length = header_length;
this->_header_length = (uint8_t) header_length;
this->_buffer = buffer;
}

View File

@ -64,7 +64,6 @@ namespace ts {
inline bool fragmentable() { return *this == PacketTypeInfo::Command || *this == PacketTypeInfo::CommandLow; }
inline bool compressable() { return *this == PacketTypeInfo::Command || *this == PacketTypeInfo::CommandLow; }
PacketTypeInfo(PacketTypeInfo&);
PacketTypeInfo(const PacketTypeInfo&);
PacketTypeInfo(PacketTypeInfo&& remote) : data(remote.data) {}
@ -88,7 +87,7 @@ namespace ts {
PacketIdManager() : data(new PacketIdManagerData){}
~PacketIdManager() = default;
PacketIdManager(const PacketIdManager& ref) : data(ref.data) {}
PacketIdManager(PacketIdManager& ref) : data(ref.data) {}
PacketIdManager(PacketIdManager&& ref) : data(std::move(ref.data)) {}
uint16_t nextPacketId(const PacketTypeInfo &type){
return static_cast<uint16_t>(data->packetCounter[type.type()]++ & 0xFFFF);

View File

@ -5,7 +5,9 @@ using namespace ts;
using namespace ts::protocol;
using namespace ts::buffer;
#pragma GCC optimize ("O3")
#ifndef WIN32
#pragma GCC optimize ("O3")
#endif
meminfo buffer::buffer_memory() {
size_t bytes_buffer = 0;

View File

@ -5,7 +5,9 @@ using namespace ts;
using namespace ts::protocol;
using namespace ts::buffer;
#pragma GCC optimize ("O3")
#ifndef WIN32
#pragma GCC optimize ("O3")
#endif
buffer_t buffer::allocate_buffer(size::value size) {
return pipes::buffer{buffer::size::byte_length(size)};

View File

@ -111,7 +111,9 @@ namespace ts {
key = data.substr(current_index, index_assign - current_index);
try {
value = query::unescape(string(data.substr(index_assign + 1, end_index - index_assign - 1)), true);
} catch(std::invalid_argument& ex) {
} catch(const std::invalid_argument& ex) {
(void) ex;
/* invalid character at index X */
if(!drop_non_utf8)
throw;

View File

@ -179,12 +179,12 @@ operator type(){ \
Json::Value buildJson() const;
#endif
const ParameterBulk& operator[](int index) const {
const ParameterBulk& operator[](size_t index) const {
if(bulks.size() <= index) throw std::invalid_argument("got out of length");
return bulks[index];
}
ParameterBulk& operator[](int index){
ParameterBulk& operator[](size_t index){
while(bulks.size() <= index) bulks.push_back(ParameterBulk{});
return bulks[index];
}

View File

@ -143,7 +143,9 @@ command command::parse(const std::string_view &data, bool expect_type, bool drop
key = data.substr(current_index, index_assign - current_index);
try {
value = query::unescape(string(data.substr(index_assign + 1, end_index - index_assign - 1)), true);
} catch(std::invalid_argument& ex) {
} catch(const std::invalid_argument& ex) {
(void) ex;
/* invalid character at index X */
if(!drop_non_utf8)
throw;