2023-05-16 07:34:06 +07:00
|
|
|
#include "version.h"
|
2020-12-26 15:03:51 +03:00
|
|
|
#include "localserver.h"
|
|
|
|
|
#include "systemservice.h"
|
|
|
|
|
|
2023-09-14 19:44:17 +03:00
|
|
|
|
|
|
|
|
#ifdef Q_OS_WIN
|
|
|
|
|
#include "platforms/windows/daemon/windowsdaemontunnel.h"
|
|
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
int s_argc = 0;
|
|
|
|
|
char** s_argv = nullptr;
|
|
|
|
|
} // namespace
|
|
|
|
|
#endif
|
|
|
|
|
|
2020-12-26 15:03:51 +03:00
|
|
|
SystemService::SystemService(int argc, char **argv)
|
|
|
|
|
: QtService<QCoreApplication>(argc, argv, SERVICE_NAME)
|
|
|
|
|
{
|
2025-03-25 16:12:13 +01:00
|
|
|
setServiceDescription("Service for DefaultVPN");
|
2023-09-14 19:44:17 +03:00
|
|
|
|
|
|
|
|
#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
|
|
|
|
|
|
2020-12-26 15:03:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SystemService::start()
|
|
|
|
|
{
|
|
|
|
|
QCoreApplication* app = application();
|
2020-12-26 23:17:20 +03:00
|
|
|
m_localServer = new LocalServer();
|
2020-12-26 15:03:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SystemService::stop()
|
|
|
|
|
{
|
|
|
|
|
delete m_localServer;
|
|
|
|
|
}
|