Improved the code quality and TeaSpeak now builds with clang
This commit is contained in:
parent
39d1959dde
commit
76f22ff337
@ -1,7 +1,7 @@
|
|||||||
cmake_minimum_required(VERSION 3.6)
|
cmake_minimum_required(VERSION 3.6)
|
||||||
project(TeaSpeak-Files)
|
project(TeaSpeak-Files)
|
||||||
|
|
||||||
#set(CMAKE_CXX_STANDARD 17)
|
#set(CMAKE_CXX_STANDARD 20)
|
||||||
#set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
#set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
add_library(TeaSpeak-FileServer STATIC
|
add_library(TeaSpeak-FileServer STATIC
|
||||||
@ -27,6 +27,7 @@ target_link_libraries(TeaSpeak-FileServer PUBLIC TeaSpeak ${StringVariable_LIBRA
|
|||||||
|
|
||||||
target_include_directories(TeaSpeak-FileServer PUBLIC include/)
|
target_include_directories(TeaSpeak-FileServer PUBLIC include/)
|
||||||
target_compile_options(TeaSpeak-FileServer PUBLIC "-Wswitch-enum")
|
target_compile_options(TeaSpeak-FileServer PUBLIC "-Wswitch-enum")
|
||||||
|
target_compile_features(TeaSpeak-FileServer PUBLIC cxx_std_20)
|
||||||
|
|
||||||
add_executable(TeaSpeak-FileServerTest test/main.cpp)
|
add_executable(TeaSpeak-FileServerTest test/main.cpp)
|
||||||
target_link_libraries(TeaSpeak-FileServerTest PUBLIC TeaSpeak-FileServer
|
target_link_libraries(TeaSpeak-FileServerTest PUBLIC TeaSpeak-FileServer
|
||||||
|
@ -23,39 +23,39 @@ bool file::initialize(std::string &error, const std::string& hostnames, uint16_t
|
|||||||
|
|
||||||
bool any_bind{false};
|
bool any_bind{false};
|
||||||
for(const auto& binding : net::resolve_bindings(hostnames, port)) {
|
for(const auto& binding : net::resolve_bindings(hostnames, port)) {
|
||||||
if(!get<2>(binding).empty()) {
|
if(!std::get<2>(binding).empty()) {
|
||||||
logError(LOG_FT, "Failed to resolve binding for {}: {}", get<0>(binding), get<2>(binding));
|
logError(LOG_FT, "Failed to resolve binding for {}: {}", std::get<0>(binding), std::get<2>(binding));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto result = dynamic_cast<transfer::LocalFileTransfer&>(server_instance->file_transfer()).add_network_binding({ get<0>(binding), get<1>(binding) });
|
auto result = dynamic_cast<transfer::LocalFileTransfer&>(server_instance->file_transfer()).add_network_binding({ std::get<0>(binding), std::get<1>(binding) });
|
||||||
switch (result) {
|
switch (result) {
|
||||||
case transfer::NetworkingBindResult::SUCCESS:
|
case transfer::NetworkingBindResult::SUCCESS:
|
||||||
any_bind = true;
|
any_bind = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case transfer::NetworkingBindResult::OUT_OF_MEMORY:
|
case transfer::NetworkingBindResult::OUT_OF_MEMORY:
|
||||||
logWarning(LOG_FT, "Failed to listen to address {}: Out of memory", get<0>(binding));
|
logWarning(LOG_FT, "Failed to listen to address {}: Out of memory", std::get<0>(binding));
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case transfer::NetworkingBindResult::FAILED_TO_LISTEN:
|
case transfer::NetworkingBindResult::FAILED_TO_LISTEN:
|
||||||
logWarning(LOG_FT, "Failed to listen on {}: {}/{}", get<0>(binding), errno, strerror(errno));
|
logWarning(LOG_FT, "Failed to listen on {}: {}/{}", std::get<0>(binding), errno, strerror(errno));
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case transfer::NetworkingBindResult::FAILED_TO_BIND:
|
case transfer::NetworkingBindResult::FAILED_TO_BIND:
|
||||||
logWarning(LOG_FT, "Failed to bind on {}: {}/{}", get<0>(binding), errno, strerror(errno));
|
logWarning(LOG_FT, "Failed to bind on {}: {}/{}", std::get<0>(binding), errno, strerror(errno));
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case transfer::NetworkingBindResult::BINDING_ALREADY_EXISTS:
|
case transfer::NetworkingBindResult::BINDING_ALREADY_EXISTS:
|
||||||
logWarning(LOG_FT, "Failed to bind on {}: binding already exists", get<0>(binding));
|
logWarning(LOG_FT, "Failed to bind on {}: binding already exists", std::get<0>(binding));
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case transfer::NetworkingBindResult::NETWORKING_NOT_INITIALIZED:
|
case transfer::NetworkingBindResult::NETWORKING_NOT_INITIALIZED:
|
||||||
logWarning(LOG_FT, "Failed to bind on {}: networking not initialized", get<0>(binding));
|
logWarning(LOG_FT, "Failed to bind on {}: networking not initialized", std::get<0>(binding));
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case transfer::NetworkingBindResult::FAILED_TO_ALLOCATE_SOCKET:
|
case transfer::NetworkingBindResult::FAILED_TO_ALLOCATE_SOCKET:
|
||||||
logWarning(LOG_FT, "Failed to allocate a socket for {}: {}/{}", get<0>(binding), errno, strerror(errno));
|
logWarning(LOG_FT, "Failed to allocate a socket for {}: {}/{}", std::get<0>(binding), errno, strerror(errno));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit d09428739c651d897ae5b00b394139891050428a
|
Subproject commit be995e99c45ff7e5ba4adb36529a53558e06fa61
|
@ -422,7 +422,7 @@ namespace license {
|
|||||||
#ifdef GOOGLE_PROTOBUF_MESSAGE_H__
|
#ifdef GOOGLE_PROTOBUF_MESSAGE_H__
|
||||||
packet(PacketType packetId, const ::google::protobuf::Message&);
|
packet(PacketType packetId, const ::google::protobuf::Message&);
|
||||||
#endif
|
#endif
|
||||||
packet(PacketType packetId, nullptr_t);
|
packet(PacketType packetId, std::nullptr_t);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
2
rtclib
2
rtclib
@ -1 +1 @@
|
|||||||
Subproject commit f8c063fbb51a66460b22dff7126c61bdb3cab4ca
|
Subproject commit fb969956dfcf86f2ce6ffb324d8fd786bda236c4
|
@ -355,7 +355,7 @@ target_link_libraries(Snapshots-Permissions-Test PUBLIC
|
|||||||
|
|
||||||
#Require a so
|
#Require a so
|
||||||
sqlite3
|
sqlite3
|
||||||
DataPipes::rtc::shared
|
DataPipes::core::static
|
||||||
|
|
||||||
tomcrypt::static
|
tomcrypt::static
|
||||||
tommath::static
|
tommath::static
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#include <dlfcn.h>
|
|
||||||
#include <client/linux/handler/exception_handler.h>
|
//include <iterator> /* Required for breakpad */
|
||||||
|
//#include <client/linux/handler/exception_handler.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <misc/strobf.h>
|
#include <misc/strobf.h>
|
||||||
#include <CXXTerminal/QuickTerminal.h>
|
#include <CXXTerminal/QuickTerminal.h>
|
||||||
@ -14,7 +15,10 @@
|
|||||||
#include "src/terminal/CommandHandler.h"
|
#include "src/terminal/CommandHandler.h"
|
||||||
#include "src/client/InternalClient.h"
|
#include "src/client/InternalClient.h"
|
||||||
#include "src/SignalHandler.h"
|
#include "src/SignalHandler.h"
|
||||||
#include "src/build.h"
|
|
||||||
|
#include <dlfcn.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <sys/resource.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace std::chrono;
|
using namespace std::chrono;
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
|
|
||||||
#include <breakpad/client/linux/handler/exception_handler.h>
|
|
||||||
#include "VirtualServer.h"
|
#include "VirtualServer.h"
|
||||||
#include "SignalHandler.h"
|
#include "SignalHandler.h"
|
||||||
#include "VirtualServerManager.h"
|
#include "VirtualServerManager.h"
|
||||||
@ -10,15 +9,25 @@
|
|||||||
#include <experimental/filesystem>
|
#include <experimental/filesystem>
|
||||||
#include <src/terminal/PipedTerminal.h>
|
#include <src/terminal/PipedTerminal.h>
|
||||||
|
|
||||||
|
#include <iterator>
|
||||||
|
|
||||||
|
#define BREAKPAD_EXCEPTION_HANDLER 1
|
||||||
|
#ifdef BREAKPAD_EXCEPTION_HANDLER
|
||||||
|
#include <breakpad/client/linux/handler/exception_handler.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
namespace fs = std::experimental::filesystem;
|
namespace fs = std::experimental::filesystem;
|
||||||
|
|
||||||
|
#ifdef BREAKPAD_EXCEPTION_HANDLER
|
||||||
google_breakpad::ExceptionHandler* globalExceptionHandler = nullptr;
|
google_breakpad::ExceptionHandler* globalExceptionHandler = nullptr;
|
||||||
|
#endif
|
||||||
#define SIG(s, c) \
|
#define SIG(s, c) \
|
||||||
if(signal(s, c) != nullptr) logError(LOG_GENERAL, "Cant setup signal handler for " #s);
|
if(signal(s, c) != nullptr) logError(LOG_GENERAL, "Cant setup signal handler for " #s);
|
||||||
|
|
||||||
|
|
||||||
extern bool mainThreadDone;
|
extern bool mainThreadDone;
|
||||||
|
#ifdef BREAKPAD_EXCEPTION_HANDLER
|
||||||
static bool dumpCallback(const google_breakpad::MinidumpDescriptor& descriptor, void* context, bool succeeded) {
|
static bool dumpCallback(const google_breakpad::MinidumpDescriptor& descriptor, void* context, bool succeeded) {
|
||||||
logCritical(LOG_GENERAL, "The server crashed!");
|
logCritical(LOG_GENERAL, "The server crashed!");
|
||||||
try {
|
try {
|
||||||
@ -41,6 +50,7 @@ static bool dumpCallback(const google_breakpad::MinidumpDescriptor& descriptor,
|
|||||||
logCritical(LOG_GENERAL, " Message: {}", ex.what());
|
logCritical(LOG_GENERAL, " Message: {}", ex.what());
|
||||||
} catch(...) {}
|
} catch(...) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
logCritical(LOG_GENERAL, "Please report this crash to the TeaSpeak maintainer WolverinDEV");
|
logCritical(LOG_GENERAL, "Please report this crash to the TeaSpeak maintainer WolverinDEV");
|
||||||
logCritical(LOG_GENERAL, "Official issue and bug tracker url: https://github.com/TeaSpeak/TeaSpeak/issues");
|
logCritical(LOG_GENERAL, "Official issue and bug tracker url: https://github.com/TeaSpeak/TeaSpeak/issues");
|
||||||
logCritical(LOG_GENERAL, "Any reports of crashes are useless if you not provide the above generated crashlog!");
|
logCritical(LOG_GENERAL, "Any reports of crashes are useless if you not provide the above generated crashlog!");
|
||||||
@ -51,15 +61,20 @@ static bool dumpCallback(const google_breakpad::MinidumpDescriptor& descriptor,
|
|||||||
while(!mainThreadDone) threads::self::sleep_for(chrono::seconds(1));
|
while(!mainThreadDone) threads::self::sleep_for(chrono::seconds(1));
|
||||||
return succeeded;
|
return succeeded;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
std::atomic spawn_failed_count = 0;
|
std::atomic spawn_failed_count = 0;
|
||||||
bool ts::syssignal::setup() {
|
bool ts::syssignal::setup() {
|
||||||
logMessage(LOG_GENERAL, "Setting up exception handler");
|
logMessage(LOG_GENERAL, "Setting up exception handler");
|
||||||
|
#ifdef BREAKPAD_EXCEPTION_HANDLER
|
||||||
globalExceptionHandler = new google_breakpad::ExceptionHandler(google_breakpad::MinidumpDescriptor("."), nullptr, dumpCallback, nullptr, true, -1);
|
globalExceptionHandler = new google_breakpad::ExceptionHandler(google_breakpad::MinidumpDescriptor("."), nullptr, dumpCallback, nullptr, true, -1);
|
||||||
|
#endif
|
||||||
|
|
||||||
SIG(SIGTERM, &ts::syssignal::handleStopSignal);
|
SIG(SIGTERM, &ts::syssignal::handleStopSignal);
|
||||||
if(isatty(fileno(stdin))) //We cant listen for this signal if stdin ist a atty
|
if(isatty(fileno(stdin))) {
|
||||||
|
//We cant listen for this signal if stdin ist a atty
|
||||||
SIG(SIGINT, &ts::syssignal::handleStopSignal);
|
SIG(SIGINT, &ts::syssignal::handleStopSignal);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
#ifdef COMPILE_WEB_CLIENT
|
#ifdef COMPILE_WEB_CLIENT
|
||||||
#include <pipes/ssl.h>
|
#include <pipes/ssl.h>
|
||||||
#include <pipes/ws.h>
|
#include <pipes/ws.h>
|
||||||
#include <pipes/rtc/PeerConnection.h>
|
|
||||||
#include <src/client/SpeakingClient.h>
|
#include <src/client/SpeakingClient.h>
|
||||||
#include <src/client/ConnectedClient.h>
|
#include <src/client/ConnectedClient.h>
|
||||||
#include <protocol/buffers.h>
|
#include <protocol/buffers.h>
|
||||||
|
2
shared
2
shared
@ -1 +1 @@
|
|||||||
Subproject commit 7b51bcc5e82802ea8173da8c341ff31614f1c49b
|
Subproject commit 23db0edd229a4cc37390bfc5df870d7aaf191f03
|
Loading…
x
Reference in New Issue
Block a user