From 101838404ee03c9120e66781eb34e813326866d6 Mon Sep 17 00:00:00 2001 From: "vladimir.kuznetsov" Date: Thu, 13 Feb 2025 22:47:13 +0700 Subject: [PATCH] bugfix: fixed possible crush on android --- CMakeLists.txt | 4 ++-- client/amnezia_application.cpp | 19 +++++++++++-------- client/core/controllers/apiController.cpp | 8 ++++---- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 98397bbb1..22141c9dd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.25.0 FATAL_ERROR) set(PROJECT AmneziaVPN) -project(${PROJECT} VERSION 4.8.3.2 +project(${PROJECT} VERSION 4.8.3.3 DESCRIPTION "AmneziaVPN" HOMEPAGE_URL "https://amnezia.org/" ) @@ -11,7 +11,7 @@ string(TIMESTAMP CURRENT_DATE "%Y-%m-%d") set(RELEASE_DATE "${CURRENT_DATE}") set(APP_MAJOR_VERSION ${CMAKE_PROJECT_VERSION_MAJOR}.${CMAKE_PROJECT_VERSION_MINOR}.${CMAKE_PROJECT_VERSION_PATCH}) -set(APP_ANDROID_VERSION_CODE 2075) +set(APP_ANDROID_VERSION_CODE 2076) if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") set(MZ_PLATFORM_NAME "linux") diff --git a/client/amnezia_application.cpp b/client/amnezia_application.cpp index aeed439b6..8706be587 100644 --- a/client/amnezia_application.cpp +++ b/client/amnezia_application.cpp @@ -2,6 +2,8 @@ #include #include +#include +#include #include #include #include @@ -10,8 +12,6 @@ #include #include #include -#include -#include #include "logger.h" #include "ui/models/installedAppsModel.h" @@ -282,16 +282,17 @@ bool AmneziaApplication::parseCommands() } #if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS) -void AmneziaApplication::startLocalServer() { +void AmneziaApplication::startLocalServer() +{ const QString serverName("AmneziaVPNInstance"); QLocalServer::removeServer(serverName); - QLocalServer* server = new QLocalServer(this); + QLocalServer *server = new QLocalServer(this); server->listen(serverName); QObject::connect(server, &QLocalServer::newConnection, this, [server, this]() { if (server) { - QLocalSocket* clientConnection = server->nextPendingConnection(); + QLocalSocket *clientConnection = server->nextPendingConnection(); clientConnection->deleteLater(); } emit m_pageController->raiseMainWindow(); @@ -418,7 +419,9 @@ void AmneziaApplication::initControllers() &ConnectionController::onCurrentContainerUpdated); connect(m_installController.get(), &InstallController::updateServerFromApiFinished, this, [this]() { - disconnect(m_reloadConfigErrorOccurredConnection); + if (m_reloadConfigErrorOccurredConnection) { + disconnect(m_reloadConfigErrorOccurredConnection); + } emit m_connectionController->configFromApiUpdated(); }); @@ -426,7 +429,7 @@ void AmneziaApplication::initControllers() m_reloadConfigErrorOccurredConnection = connect( m_installController.get(), qOverload(&InstallController::installationErrorOccurred), this, [this]() { emit m_vpnConnection->connectionStateChanged(Vpn::ConnectionState::Disconnected); }, - static_cast(Qt::AutoConnection || Qt::SingleShotConnection)); + static_cast(Qt::AutoConnection | Qt::SingleShotConnection)); m_installController->updateServiceFromApi(m_serversModel->getDefaultServerIndex(), "", ""); }); @@ -434,7 +437,7 @@ void AmneziaApplication::initControllers() m_reloadConfigErrorOccurredConnection = connect( m_installController.get(), qOverload(&InstallController::installationErrorOccurred), this, [this]() { emit m_vpnConnection->connectionStateChanged(Vpn::ConnectionState::Disconnected); }, - static_cast(Qt::AutoConnection || Qt::SingleShotConnection)); + static_cast(Qt::AutoConnection | Qt::SingleShotConnection)); m_serversModel->removeApiConfig(m_serversModel->getDefaultServerIndex()); m_installController->updateServiceFromTelegram(m_serversModel->getDefaultServerIndex()); }); diff --git a/client/core/controllers/apiController.cpp b/client/core/controllers/apiController.cpp index 6562632a9..2b9f71d8d 100644 --- a/client/core/controllers/apiController.cpp +++ b/client/core/controllers/apiController.cpp @@ -308,6 +308,8 @@ void ApiController::updateServerConfigFromApi(const QString &installationUuid, c if (reply->error() == QNetworkReply::NetworkError::OperationCanceledError || reply->error() == QNetworkReply::NetworkError::TimeoutError) { emit errorOccurred(ErrorCode::ApiConfigTimeoutError); + } else if (reply->error() == QNetworkReply::NetworkError::SslHandshakeFailedError) { + emit errorOccurred(ErrorCode::ApiConfigSslError); } else { QString err = reply->errorString(); qDebug() << QString::fromUtf8(reply->readAll()); @@ -323,10 +325,8 @@ void ApiController::updateServerConfigFromApi(const QString &installationUuid, c QObject::connect(reply, &QNetworkReply::errorOccurred, [this, reply](QNetworkReply::NetworkError error) { qDebug() << reply->errorString() << error; }); - connect(reply, &QNetworkReply::sslErrors, [this, reply](const QList &errors) { - qDebug().noquote() << errors; - emit errorOccurred(ErrorCode::ApiConfigSslError); - }); + + connect(reply, &QNetworkReply::sslErrors, [this, reply](const QList &errors) { qDebug().noquote() << errors; }); } }