WireGuard rework for MacOS and Windows (#314)
WireGuard rework for MacOS and Windows
This commit is contained in:
parent
421a27ceae
commit
07c38e9b6c
60 changed files with 4779 additions and 434 deletions
|
|
@ -6,7 +6,7 @@ project(${PROJECT})
|
|||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
find_package(Qt6 REQUIRED COMPONENTS Core Network RemoteObjects Core5Compat)
|
||||
find_package(Qt6 REQUIRED COMPONENTS Core Network Widgets RemoteObjects Core5Compat)
|
||||
qt_standard_project_setup()
|
||||
|
||||
configure_file(${CMAKE_SOURCE_DIR}/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/version.h)
|
||||
|
|
@ -50,7 +50,7 @@ set(HEADERS ${HEADERS}
|
|||
${CMAKE_CURRENT_LIST_DIR}/../../client/mozilla/models/server.h
|
||||
|
||||
${CMAKE_CURRENT_LIST_DIR}/../../client/mozilla/controllerimpl.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../../client/mozilla/dnspingsender.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/../../client/mozilla/dnspingsender.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../../client/mozilla/localsocketcontroller.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../../client/mozilla/networkwatcher.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/../../client/mozilla/networkwatcherimpl.h
|
||||
|
|
@ -69,7 +69,8 @@ set(SOURCES ${SOURCES}
|
|||
${CMAKE_CURRENT_LIST_DIR}/../../client/mozilla/models/server.cpp
|
||||
|
||||
${CMAKE_CURRENT_LIST_DIR}/../../client/platforms/dummy/dummynetworkwatcher.cpp
|
||||
|
||||
|
||||
${CMAKE_CURRENT_LIST_DIR}/../../client/daemon/interfaceconfig.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/../../client/mozilla/shared/ipaddress.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/../../client/mozilla/shared/leakdetector.cpp
|
||||
|
||||
|
|
@ -107,11 +108,39 @@ if(WIN32)
|
|||
set(HEADERS ${HEADERS}
|
||||
${CMAKE_CURRENT_LIST_DIR}/tapcontroller_win.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/router_win.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../client/platforms/windows/daemon/windowsdaemon.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../client/platforms/windows/daemon/windowsdaemontunnel.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../client/platforms/windows/daemon/windowsfirewall.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../client/platforms/windows/windowscommons.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../client/platforms/windows/windowsservicemanager.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../client/platforms/windows/daemon/dnsutilswindows.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../client/platforms/windows/daemon/windowssplittunnel.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../client/platforms/windows/daemon/windowstunnelservice.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../client/platforms/windows/daemon/wireguardutilswindows.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../client/platforms/windows/daemon/windowstunnellogger.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../client/platforms/windows/daemon/windowsroutemonitor.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../client/platforms/windows/windowsutils.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../client/platforms/windows/windowspingsender.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../client/platforms/windows/windowsnetworkwatcher.h
|
||||
)
|
||||
|
||||
set(SOURCES ${SOURCES}
|
||||
${CMAKE_CURRENT_LIST_DIR}/tapcontroller_win.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/router_win.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../client/platforms/windows/daemon/windowsdaemon.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../client/platforms/windows/daemon/windowsdaemontunnel.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../client/platforms/windows/daemon/windowsfirewall.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../client/platforms/windows/windowscommons.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../client/platforms/windows/windowsservicemanager.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../client/platforms/windows/daemon/dnsutilswindows.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../client/platforms/windows/daemon/windowssplittunnel.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../client/platforms/windows/daemon/windowstunnelservice.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../client/platforms/windows/daemon/wireguardutilswindows.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../client/platforms/windows/daemon/windowstunnellogger.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../client/platforms/windows/daemon/windowsroutemonitor.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../client/platforms/windows/windowspingsender.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../client/platforms/windows/windowsnetworkwatcher.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../client/platforms/windows/windowsutils.cpp
|
||||
)
|
||||
|
||||
set(LIBS
|
||||
|
|
@ -188,7 +217,7 @@ include_directories(
|
|||
)
|
||||
|
||||
add_executable(${PROJECT} ${SOURCES} ${HEADERS})
|
||||
target_link_libraries(${PROJECT} PRIVATE Qt6::Core Qt6::Network Qt6::RemoteObjects Qt6::Core5Compat ${LIBS})
|
||||
target_link_libraries(${PROJECT} PRIVATE Qt6::Core Qt6::Widgets Qt6::Network Qt6::RemoteObjects Qt6::Core5Compat ${LIBS})
|
||||
target_compile_definitions(${PROJECT} PRIVATE "MZ_$<UPPER_CASE:${MZ_PLATFORM_NAME}>")
|
||||
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
#endif
|
||||
|
||||
namespace {
|
||||
Logger logger("MacOSDaemonServer");
|
||||
Logger logger("WgDaemonServer");
|
||||
}
|
||||
|
||||
LocalServer::LocalServer(QObject *parent) : QObject(parent),
|
||||
|
|
@ -40,17 +40,25 @@ LocalServer::LocalServer(QObject *parent) : QObject(parent),
|
|||
}
|
||||
});
|
||||
|
||||
#if defined(Q_OS_MAC) || defined(Q_OS_WIN)
|
||||
// Init Mozilla Wireguard Daemon
|
||||
#ifdef Q_OS_MAC
|
||||
if (!server.initialize()) {
|
||||
logger.error() << "Failed to initialize the server";
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
// Signal handling for a proper shutdown.
|
||||
QObject::connect(qApp, &QCoreApplication::aboutToQuit,
|
||||
[]() { MacOSDaemon::instance()->deactivate(); });
|
||||
#endif
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
// Signal handling for a proper shutdown.
|
||||
QObject::connect(qApp, &QCoreApplication::aboutToQuit,
|
||||
[]() { WindowsDaemon::instance()->deactivate(); });
|
||||
#endif
|
||||
}
|
||||
|
||||
LocalServer::~LocalServer()
|
||||
|
|
|
|||
|
|
@ -10,9 +10,14 @@
|
|||
|
||||
#include "ipcserver.h"
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
#include "macos/daemon/macosdaemon.h"
|
||||
#ifdef Q_OS_WIN
|
||||
#include "../../client/daemon/daemonlocalserver.h"
|
||||
#include "windows/daemon/windowsdaemon.h"
|
||||
#endif
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
#include "../../client/daemon/daemonlocalserver.h"
|
||||
#include "macos/daemon/macosdaemon.h"
|
||||
#endif
|
||||
|
||||
class QLocalServer;
|
||||
|
|
@ -33,9 +38,13 @@ public:
|
|||
QRemoteObjectHost m_serverNode;
|
||||
bool m_isRemotingEnabled = false;
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
MacOSDaemon daemon;
|
||||
#ifdef Q_OS_WIN
|
||||
DaemonLocalServer server{qApp};
|
||||
WindowsDaemon daemon;
|
||||
#endif
|
||||
#ifdef Q_OS_MAC
|
||||
DaemonLocalServer server{qApp};
|
||||
MacOSDaemon daemon;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -6,13 +6,39 @@
|
|||
#include "systemservice.h"
|
||||
#include "utilities.h"
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
#include "platforms/windows/daemon/windowsdaemontunnel.h"
|
||||
|
||||
namespace {
|
||||
int s_argc = 0;
|
||||
char** s_argv = nullptr;
|
||||
} // namespace
|
||||
|
||||
#endif
|
||||
|
||||
int runApplication(int argc, char** argv)
|
||||
{
|
||||
QCoreApplication app(argc,argv);
|
||||
LocalServer localServer;
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
if(argc > 2){
|
||||
s_argc = argc;
|
||||
s_argv = argv;
|
||||
QStringList tokens;
|
||||
for (int i = 1; i < argc; ++i) {
|
||||
tokens.append(QString(argv[i]));
|
||||
}
|
||||
|
||||
if (!tokens.empty() && tokens[0] == "tunneldaemon") {
|
||||
WindowsDaemonTunnel *daemon = new WindowsDaemonTunnel();
|
||||
daemon->run(tokens);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
LocalServer localServer;
|
||||
return app.exec();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -22,7 +48,7 @@ int main(int argc, char **argv)
|
|||
|
||||
Logger::init();
|
||||
|
||||
if (argc == 2) {
|
||||
if (argc >= 2) {
|
||||
qInfo() << "Started as console application";
|
||||
return runApplication(argc, argv);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,10 +2,39 @@
|
|||
#include "localserver.h"
|
||||
#include "systemservice.h"
|
||||
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
#include "platforms/windows/daemon/windowsdaemontunnel.h"
|
||||
|
||||
namespace {
|
||||
int s_argc = 0;
|
||||
char** s_argv = nullptr;
|
||||
} // namespace
|
||||
#endif
|
||||
|
||||
SystemService::SystemService(int argc, char **argv)
|
||||
: QtService<QCoreApplication>(argc, argv, SERVICE_NAME)
|
||||
{
|
||||
setServiceDescription("Service for AmneziaVPN");
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
if(argc > 2){
|
||||
s_argc = argc;
|
||||
s_argv = argv;
|
||||
QStringList tokens;
|
||||
|
||||
for (int i = 1; i < argc; ++i) {
|
||||
tokens.append(QString(argv[i]));
|
||||
}
|
||||
|
||||
if (!tokens.empty() && tokens[0] == "tunneldaemon") {
|
||||
WindowsDaemonTunnel *daemon = new WindowsDaemonTunnel();
|
||||
daemon->run(tokens);
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void SystemService::start()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue