moved the function of checking the availability of wireguard config to ipc client
This commit is contained in:
parent
caad670dbf
commit
8f18933713
4 changed files with 33 additions and 19 deletions
|
|
@ -8,8 +8,7 @@
|
||||||
#include "wireguardprotocol.h"
|
#include "wireguardprotocol.h"
|
||||||
#include "utilities.h"
|
#include "utilities.h"
|
||||||
|
|
||||||
WireguardProtocol::WireguardProtocol(const QJsonObject &configuration, QObject* parent) :
|
WireguardProtocol::WireguardProtocol(const QJsonObject &configuration, QObject* parent) : VpnProtocol(configuration, parent)
|
||||||
VpnProtocol(configuration, parent)
|
|
||||||
{
|
{
|
||||||
m_configFile.setFileName(QDir::tempPath() + QDir::separator() + serviceName() + ".conf");
|
m_configFile.setFileName(QDir::tempPath() + QDir::separator() + serviceName() + ".conf");
|
||||||
writeWireguardConfiguration(configuration);
|
writeWireguardConfiguration(configuration);
|
||||||
|
|
@ -145,10 +144,17 @@ ErrorCode WireguardProtocol::start()
|
||||||
return lastError();
|
return lastError();
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (!QFileInfo::exists(configPath())) {
|
if (IpcClient::Interface()) {
|
||||||
// setLastError(ErrorCode::ConfigMissing);
|
QRemoteObjectPendingReply<bool> result = IpcClient::Interface()->isWireguardConfigExists(configPath());
|
||||||
// return lastError();
|
if (result.returnValue()) {
|
||||||
// }
|
setLastError(ErrorCode::ConfigMissing);
|
||||||
|
return lastError();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
qCritical() << "IPC client not initialized";
|
||||||
|
setLastError(ErrorCode::InternalError);
|
||||||
|
return lastError();
|
||||||
|
}
|
||||||
|
|
||||||
setConnectionState(VpnConnectionState::Connecting);
|
setConnectionState(VpnConnectionState::Connecting);
|
||||||
|
|
||||||
|
|
@ -198,7 +204,7 @@ ErrorCode WireguardProtocol::start()
|
||||||
|
|
||||||
connect(m_wireguardStartProcess.data(), &PrivilegedProcess::readyReadStandardError, this, [this]() {
|
connect(m_wireguardStartProcess.data(), &PrivilegedProcess::readyReadStandardError, this, [this]() {
|
||||||
QRemoteObjectPendingReply<QByteArray> reply = m_wireguardStartProcess->readAllStandardError();
|
QRemoteObjectPendingReply<QByteArray> reply = m_wireguardStartProcess->readAllStandardError();
|
||||||
reply.waitForFinished(1000);
|
reply.waitForFinished(10);
|
||||||
qDebug() << "WireguardProtocol::WireguardProtocol readAllStandardError" << reply.returnValue();
|
qDebug() << "WireguardProtocol::WireguardProtocol readAllStandardError" << reply.returnValue();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,5 +21,6 @@ class IpcInterface
|
||||||
|
|
||||||
SLOT( bool copyWireguardConfig(const QString &sourcePath) );
|
SLOT( bool copyWireguardConfig(const QString &sourcePath) );
|
||||||
SLOT( bool isWireguardRunning() );
|
SLOT( bool isWireguardRunning() );
|
||||||
|
SLOT( bool isWireguardConfigExists(const QString &configPath) );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QLocalSocket>
|
#include <QLocalSocket>
|
||||||
|
#include <QFileInfo>
|
||||||
|
|
||||||
#include "router.h"
|
#include "router.h"
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
|
|
@ -169,3 +170,8 @@ bool IpcServer::isWireguardRunning()
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IpcServer::isWireguardConfigExists(const QString &configPath)
|
||||||
|
{
|
||||||
|
return QFileInfo::exists(configPath);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ public:
|
||||||
virtual void setLogsEnabled(bool enabled) override;
|
virtual void setLogsEnabled(bool enabled) override;
|
||||||
virtual bool copyWireguardConfig(const QString &sourcePath) override;
|
virtual bool copyWireguardConfig(const QString &sourcePath) override;
|
||||||
virtual bool isWireguardRunning() override;
|
virtual bool isWireguardRunning() override;
|
||||||
|
virtual bool isWireguardConfigExists(const QString &configPath) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int m_localpid = 0;
|
int m_localpid = 0;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue