Merge branch 'dev' into qt_migration
This commit is contained in:
commit
442e7eb015
127 changed files with 5657 additions and 1619 deletions
|
|
@ -1,7 +1,6 @@
|
|||
#include <QCoreApplication>
|
||||
#include <QFileInfo>
|
||||
#include <QProcess>
|
||||
#include <QRegularExpression>
|
||||
#include <QTcpSocket>
|
||||
#include <QThread>
|
||||
|
||||
|
|
@ -12,25 +11,20 @@
|
|||
WireguardProtocol::WireguardProtocol(const QJsonObject &configuration, QObject* parent) :
|
||||
VpnProtocol(configuration, parent)
|
||||
{
|
||||
//m_configFile.setFileTemplate(QDir::tempPath() + QDir::separator() + serviceName() + ".conf");
|
||||
m_configFile.setFileName(QDir::tempPath() + QDir::separator() + serviceName() + ".conf");
|
||||
readWireguardConfiguration(configuration);
|
||||
}
|
||||
|
||||
WireguardProtocol::~WireguardProtocol()
|
||||
{
|
||||
//qDebug() << "WireguardProtocol::~WireguardProtocol() 1";
|
||||
WireguardProtocol::stop();
|
||||
QThread::msleep(200);
|
||||
//qDebug() << "WireguardProtocol::~WireguardProtocol() 2";
|
||||
}
|
||||
|
||||
void WireguardProtocol::stop()
|
||||
{
|
||||
//qDebug() << "WireguardProtocol::stop() 1";
|
||||
|
||||
#ifndef Q_OS_IOS
|
||||
if (!QFileInfo::exists(wireguardExecPath())) {
|
||||
if (!QFileInfo::exists(Utils::wireguardExecPath())) {
|
||||
qCritical() << "Wireguard executable missing!";
|
||||
setLastError(ErrorCode::ExecutableMissing);
|
||||
return;
|
||||
|
|
@ -51,7 +45,7 @@ void WireguardProtocol::stop()
|
|||
return;
|
||||
}
|
||||
|
||||
m_wireguardStopProcess->setProgram(wireguardExecPath());
|
||||
m_wireguardStopProcess->setProgram(PermittedProcess::Wireguard);
|
||||
|
||||
|
||||
QStringList arguments({"--remove", configPath()});
|
||||
|
|
@ -74,7 +68,6 @@ void WireguardProtocol::stop()
|
|||
setConnectionState(VpnProtocol::Disconnected);
|
||||
#endif
|
||||
|
||||
//qDebug() << "WireguardProtocol::stop() 2";
|
||||
}
|
||||
|
||||
void WireguardProtocol::readWireguardConfiguration(const QJsonObject &configuration)
|
||||
|
|
@ -97,11 +90,6 @@ void WireguardProtocol::readWireguardConfiguration(const QJsonObject &configurat
|
|||
|
||||
}
|
||||
|
||||
//bool WireguardProtocol::openVpnProcessIsRunning() const
|
||||
//{
|
||||
// return Utils::processIsRunning("openvpn");
|
||||
//}
|
||||
|
||||
QString WireguardProtocol::configPath() const
|
||||
{
|
||||
return m_configFileName;
|
||||
|
|
@ -117,31 +105,17 @@ void WireguardProtocol::updateRouteGateway(QString line)
|
|||
qDebug() << "Set VPN route gateway" << m_routeGateway;
|
||||
}
|
||||
|
||||
QString WireguardProtocol::wireguardExecPath() const
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
return Utils::executable("wireguard/wireguard-service", true);
|
||||
#elif defined Q_OS_LINUX
|
||||
return Utils::usrExecutable("wg");
|
||||
#else
|
||||
return Utils::executable("/wireguard", true);
|
||||
#endif
|
||||
}
|
||||
|
||||
ErrorCode WireguardProtocol::start()
|
||||
{
|
||||
//qDebug() << "WireguardProtocol::start() 1";
|
||||
|
||||
#ifndef Q_OS_IOS
|
||||
if (!m_isConfigLoaded) {
|
||||
setLastError(ErrorCode::ConfigMissing);
|
||||
return lastError();
|
||||
}
|
||||
|
||||
//qDebug() << "Start Wireguard connection";
|
||||
WireguardProtocol::stop();
|
||||
|
||||
if (!QFileInfo::exists(wireguardExecPath())) {
|
||||
if (!QFileInfo::exists(Utils::wireguardExecPath())) {
|
||||
setLastError(ErrorCode::ExecutableMissing);
|
||||
return lastError();
|
||||
}
|
||||
|
|
@ -156,7 +130,6 @@ ErrorCode WireguardProtocol::start()
|
|||
m_wireguardStartProcess = IpcClient::CreatePrivilegedProcess();
|
||||
|
||||
if (!m_wireguardStartProcess) {
|
||||
//qWarning() << "IpcProcess replica is not created!";
|
||||
setLastError(ErrorCode::AmneziaServiceConnectionFailed);
|
||||
return ErrorCode::AmneziaServiceConnectionFailed;
|
||||
}
|
||||
|
|
@ -168,7 +141,7 @@ ErrorCode WireguardProtocol::start()
|
|||
return ErrorCode::AmneziaServiceConnectionFailed;
|
||||
}
|
||||
|
||||
m_wireguardStartProcess->setProgram(wireguardExecPath());
|
||||
m_wireguardStartProcess->setProgram(PermittedProcess::Wireguard);
|
||||
|
||||
|
||||
QStringList arguments({"--add", configPath()});
|
||||
|
|
@ -210,8 +183,6 @@ ErrorCode WireguardProtocol::start()
|
|||
m_wireguardStartProcess->start();
|
||||
m_wireguardStartProcess->waitForFinished(10000);
|
||||
|
||||
//qDebug() << "WireguardProtocol::start() 2";
|
||||
|
||||
return ErrorCode::NoError;
|
||||
#else
|
||||
return ErrorCode::NotImplementedError;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue