2021-06-12 11:59:36 +03:00
|
|
|
#ifndef WIREGUARDPROTOCOL_H
|
|
|
|
|
#define WIREGUARDPROTOCOL_H
|
|
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
|
#include <QProcess>
|
|
|
|
|
#include <QString>
|
|
|
|
|
#include <QTemporaryFile>
|
|
|
|
|
#include <QTimer>
|
|
|
|
|
|
|
|
|
|
#include "vpnprotocol.h"
|
|
|
|
|
#include "core/ipcclient.h"
|
|
|
|
|
|
2023-07-15 14:19:48 -07:00
|
|
|
#include "mozilla/controllerimpl.h"
|
|
|
|
|
|
2021-06-12 11:59:36 +03:00
|
|
|
class WireguardProtocol : public VpnProtocol
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
explicit WireguardProtocol(const QJsonObject& configuration, QObject* parent = nullptr);
|
|
|
|
|
virtual ~WireguardProtocol() override;
|
|
|
|
|
|
|
|
|
|
ErrorCode start() override;
|
|
|
|
|
void stop() override;
|
|
|
|
|
|
2023-09-17 17:06:24 -04:00
|
|
|
#if defined(Q_OS_MAC) || defined(Q_OS_WIN) || defined(Q_OS_LINUX)
|
2023-07-15 14:19:48 -07:00
|
|
|
ErrorCode startMzImpl();
|
|
|
|
|
ErrorCode stopMzImpl();
|
|
|
|
|
#endif
|
|
|
|
|
|
2021-06-12 11:59:36 +03:00
|
|
|
private:
|
|
|
|
|
QString configPath() const;
|
2023-01-24 09:43:12 +03:00
|
|
|
void writeWireguardConfiguration(const QJsonObject &configuration);
|
2021-06-12 11:59:36 +03:00
|
|
|
|
|
|
|
|
void updateRouteGateway(QString line);
|
|
|
|
|
void updateVpnGateway(const QString &line);
|
|
|
|
|
QString serviceName() const;
|
2023-02-28 17:16:38 +03:00
|
|
|
QStringList stopArgs();
|
|
|
|
|
QStringList startArgs();
|
2021-06-12 11:59:36 +03:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
QString m_configFileName;
|
|
|
|
|
QFile m_configFile;
|
|
|
|
|
|
2021-11-19 19:02:39 +03:00
|
|
|
QSharedPointer<PrivilegedProcess> m_wireguardStartProcess;
|
|
|
|
|
QSharedPointer<PrivilegedProcess> m_wireguardStopProcess;
|
2021-06-12 11:59:36 +03:00
|
|
|
|
|
|
|
|
bool m_isConfigLoaded = false;
|
|
|
|
|
|
2023-09-17 17:06:24 -04:00
|
|
|
#if defined(Q_OS_MAC) || defined(Q_OS_WIN) || defined(Q_OS_LINUX)
|
2023-07-15 14:19:48 -07:00
|
|
|
QScopedPointer<ControllerImpl> m_impl;
|
|
|
|
|
#endif
|
2021-06-12 11:59:36 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // WIREGUARDPROTOCOL_H
|