2023-09-14 19:44:17 +03:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
|
|
#ifndef WINDOWSTUNNELSERVICE_H
|
|
|
|
|
#define WINDOWSTUNNELSERVICE_H
|
|
|
|
|
|
|
|
|
|
#include <QFile>
|
|
|
|
|
#include <QObject>
|
|
|
|
|
#include <QThread>
|
|
|
|
|
#include <QTimer>
|
2026-05-25 14:53:50 +00:00
|
|
|
#include <string>
|
2023-09-14 19:44:17 +03:00
|
|
|
|
|
|
|
|
#include "windowstunnellogger.h"
|
|
|
|
|
|
|
|
|
|
class WindowsTunnelService final : public QObject {
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
Q_DISABLE_COPY_MOVE(WindowsTunnelService)
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
WindowsTunnelService(QObject* parent = nullptr);
|
|
|
|
|
~WindowsTunnelService();
|
|
|
|
|
|
2026-05-25 14:53:50 +00:00
|
|
|
bool start(const QString& configData, const QString& ifname);
|
2023-09-14 19:44:17 +03:00
|
|
|
void stop();
|
|
|
|
|
bool isRunning();
|
|
|
|
|
QString uapiCommand(const QString& command);
|
|
|
|
|
|
2026-05-25 14:53:50 +00:00
|
|
|
static std::wstring serviceNameForIfname(const QString& ifname);
|
|
|
|
|
|
2023-09-14 19:44:17 +03:00
|
|
|
signals:
|
|
|
|
|
void backendFailure();
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
void timeout();
|
|
|
|
|
static QString exitCodeToFailure(const void* status);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
QTimer m_timer;
|
|
|
|
|
QThread m_logthread;
|
|
|
|
|
WindowsTunnelLogger* m_logworker = nullptr;
|
2026-05-25 14:53:50 +00:00
|
|
|
QString m_ifname;
|
2023-09-14 19:44:17 +03:00
|
|
|
|
|
|
|
|
// These are really SC_HANDLEs in disguise.
|
|
|
|
|
void* m_scm = nullptr;
|
|
|
|
|
void* m_service = nullptr;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // WINDOWSTUNNELSERVICE_H
|