WireGuard rework for MacOS and Windows (#314)

WireGuard rework for MacOS and Windows
This commit is contained in:
Mykola Baibuz 2023-09-14 19:44:17 +03:00 committed by GitHub
parent 421a27ceae
commit 07c38e9b6c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
60 changed files with 4779 additions and 434 deletions

View file

@ -18,7 +18,7 @@ WireguardProtocol::WireguardProtocol(const QJsonObject &configuration, QObject*
// MZ
#if defined(MZ_LINUX)
//m_impl.reset(new LinuxController());
#elif defined(MZ_MACOS) // || defined(MZ_WINDOWS)
#elif defined(Q_OS_MAC) || defined(Q_OS_WIN)
m_impl.reset(new LocalSocketController());
connect(m_impl.get(), &ControllerImpl::connected, this, [this](const QString& pubkey, const QDateTime& connectionTimestamp) {
emit connectionStateChanged(VpnProtocol::Connected);
@ -38,7 +38,7 @@ WireguardProtocol::~WireguardProtocol()
void WireguardProtocol::stop()
{
#ifdef Q_OS_MAC
#if defined(Q_OS_MAC) || defined(Q_OS_WIN)
stopMzImpl();
return;
#endif
@ -98,9 +98,11 @@ void WireguardProtocol::stop()
setConnectionState(VpnProtocol::Disconnected);
}
#ifdef Q_OS_MAC
#if defined(Q_OS_MAC) || defined(Q_OS_WIN)
ErrorCode WireguardProtocol::startMzImpl()
{
qDebug() << "WireguardProtocol::startMzImpl():" << m_rawConfig;
m_impl->activate(m_rawConfig);
return ErrorCode::NoError;
}
@ -169,7 +171,7 @@ ErrorCode WireguardProtocol::start()
return lastError();
}
#ifdef Q_OS_MAC
#if defined(Q_OS_MAC) || defined(Q_OS_WIN)
return startMzImpl();
#endif

View file

@ -23,7 +23,7 @@ public:
ErrorCode start() override;
void stop() override;
#ifdef Q_OS_MAC
#if defined(Q_OS_MAC) || defined(Q_OS_WIN)
ErrorCode startMzImpl();
ErrorCode stopMzImpl();
#endif
@ -47,7 +47,7 @@ private:
bool m_isConfigLoaded = false;
#ifdef Q_OS_MAC
#if defined(Q_OS_MAC) || defined(Q_OS_WIN)
QScopedPointer<ControllerImpl> m_impl;
#endif
};