Add checking background service before connect (#716)

checking if the service is running for all platforms
This commit is contained in:
Vladyslav Miachkov 2024-05-10 13:06:04 +03:00 committed by GitHub
parent d67c378bff
commit ff348a348c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 20 additions and 4 deletions

View file

@ -7,9 +7,11 @@
#endif
#include <QtConcurrent>
#include "utilities.h"
#include "core/controllers/apiController.h"
#include "core/controllers/vpnConfigurationController.h"
#include "core/errorstrings.h"
#include "version.h"
ConnectionController::ConnectionController(const QSharedPointer<ServersModel> &serversModel,
const QSharedPointer<ContainersModel> &containersModel,
@ -32,6 +34,14 @@ ConnectionController::ConnectionController(const QSharedPointer<ServersModel> &s
void ConnectionController::openConnection()
{
#if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS)
if (!Utils::processIsRunning(Utils::executable(SERVICE_NAME, false), true))
{
emit connectionErrorOccurred(errorString(ErrorCode::AmneziaServiceNotRunning));
return;
}
#endif
int serverIndex = m_serversModel->getDefaultServerIndex();
auto serverConfig = m_serversModel->getServerConfig(serverIndex);