From 3d60ac751eefa101bbeb8ae5fcf3bb1cd57a969f Mon Sep 17 00:00:00 2001 From: "vladimir.kuznetsov" Date: Fri, 20 Oct 2023 20:52:14 +0500 Subject: [PATCH] removed the default protocol/server change if connected to VPN --- client/translations/amneziavpn_ru.ts | 130 +++++++++--------- client/translations/amneziavpn_zh_CN.ts | 130 +++++++++--------- client/ui/controllers/importController.cpp | 2 - client/ui/controllers/installController.cpp | 5 - client/ui/models/containers_model.cpp | 9 +- client/ui/models/containers_model.h | 1 + .../qml/Pages2/PageSetupWizardInstalling.qml | 8 ++ .../qml/Pages2/PageSetupWizardViewConfig.qml | 4 + 8 files changed, 151 insertions(+), 138 deletions(-) diff --git a/client/translations/amneziavpn_ru.ts b/client/translations/amneziavpn_ru.ts index 733c374d..8c72f093 100644 --- a/client/translations/amneziavpn_ru.ts +++ b/client/translations/amneziavpn_ru.ts @@ -135,7 +135,7 @@ ImportController - + Scanned %1 of %2. Отсканировано %1 из%2. @@ -144,13 +144,13 @@ InstallController - + %1 installed successfully. %1 успешно установлен. - + %1 is already installed on the server. %1 уже установлен на сервер. @@ -162,39 +162,39 @@ Added containers that were already installed on the server В приложение добавлены обнаруженные на сервере протоклы и сервисы - + Already installed containers were found on the server. All installed containers have been added to the application На сервере обнаружены установленные протоколы и сервисы, все они добавлены в приложение - + Settings updated successfully Настройки успешно обновлены - + Server '%1' was removed Сервер '%1' был удален - + All containers from server '%1' have been removed Все протоклы и сервисы были удалены с сервера '%1' - + %1 has been removed from the server '%2' %1 был удален с сервера '%2' - + Please login as the user Пожалуйста, войдите в систему от имени пользователя - + Server added successfully Сервер успешно добавлен @@ -397,195 +397,195 @@ Already installed containers were found on the server. All installed containers PageProtocolOpenVpnSettings - + OpenVPN settings Настройки OpenVPN - + VPN Addresses Subnet VPN Адреса Подсеть - + Network protocol Сетевой протокол - + Port Порт - + Auto-negotiate encryption Шифрование с автоматическим согласованием - + Hash Хэш - + SHA512 SHA512 - + SHA384 SHA384 - + SHA256 SHA256 - + SHA3-512 SHA3-512 - + SHA3-384 SHA3-384 - + SHA3-256 SHA3-256 - + whirlpool whirlpool - + BLAKE2b512 BLAKE2b512 - + BLAKE2s256 BLAKE2s256 - + SHA1 SHA1 - + Cipher Шифрование - + AES-256-GCM AES-256-GCM - + AES-192-GCM AES-192-GCM - + AES-128-GCM AES-128-GCM - + AES-256-CBC AES-256-CBC - + AES-192-CBC AES-192-CBC - + AES-128-CBC AES-128-CBC - + ChaCha20-Poly1305 ChaCha20-Poly1305 - + ARIA-256-CBC ARIA-256-CBC - + CAMELLIA-256-CBC CAMELLIA-256-CBC - + none none - + TLS auth TLS авторизация - + Block DNS requests outside of VPN Блокировать DNS запросы за пределами VPN - + Additional client configuration commands Дополнительные команды конфигурации клиента - - + + Commands: Commands: - + Additional server configuration commands Дополнительные команды конфигурации сервера - + Remove OpenVPN Удалить OpenVPN - + Remove OpenVpn from server? Удалить OpenVpn с сервера? - + All users who you shared a connection with will no longer be able to connect to it. Все пользователи, с которыми вы поделились этим VPN-протоколом, больше не смогут к нему подключаться. - + Continue Продолжить - + Cancel Отменить - + Save and Restart Amnezia Сохранить и перезагрузить @@ -608,27 +608,27 @@ Already installed containers were found on the server. All installed containers Параметры подключения %1 - + Remove Удалить - + Remove %1 from server? Удалить %1 с сервера? - + All users who you shared a connection with will no longer be able to connect to it. Все пользователи, с которыми вы поделились этим VPN-протоколом, больше не смогут к нему подключаться. - + Continue Продолжить - + Cancel Отменить @@ -1694,7 +1694,7 @@ and will not be shared or disclosed to the Amnezia or any third parties PageSetupWizardInstalling - + The server has already been added to the application Сервер уже был добавлен в приложение @@ -1707,28 +1707,28 @@ and will not be shared or disclosed to the Amnezia or any third parties занят установкой других протоколов или сервисов. Установка Amnesia - + Amnezia has detected that your server is currently Amnezia обнаружила, что ваш сервер в настоящее время - + busy installing other software. Amnezia installation занят установкой другого программного обеспечения. Установка Amnezia - + will pause until the server finishes installing other software будет приостановлена до тех пор, пока сервер не завершит установку - + Installing Установка - + Usually it takes no more than 5 minutes Обычно это занимает не более 5 минут @@ -1846,27 +1846,27 @@ and will not be shared or disclosed to the Amnezia or any third parties PageSetupWizardViewConfig - + New connection Новое соединение - + Do not use connection code from public sources. It could be created to intercept your data. Не используйте код подключения из публичных источников. Его могли создать, чтобы перехватывать ваши данные. - + Collapse content Свернуть - + Show content Показать содержимое ключа - + Connect Подключиться diff --git a/client/translations/amneziavpn_zh_CN.ts b/client/translations/amneziavpn_zh_CN.ts index 64faa6f4..10064ce2 100644 --- a/client/translations/amneziavpn_zh_CN.ts +++ b/client/translations/amneziavpn_zh_CN.ts @@ -146,7 +146,7 @@ ImportController - + Scanned %1 of %2. 扫描 %1 of %2. @@ -163,13 +163,13 @@ - + %1 installed successfully. %1 安装成功。 - + %1 is already installed on the server. 服务器上已经安装 %1。 @@ -180,29 +180,29 @@ Added containers that were already installed on the server 添加已安装在服务器上的容器 - + Already installed containers were found on the server. All installed containers have been added to the application 在服务上发现已经安装协议并添加至应用 - + Settings updated successfully 配置更新成功 - + Server '%1' was removed 已移除服务器 '%1' - + All containers from server '%1' have been removed 服务器 '%1' 的所有容器已移除 - + %1 has been removed from the server '%2' %1 已从服务器 '%2' 上移除 @@ -223,12 +223,12 @@ Already installed containers were found on the server. All installed containers 协议已从 - + Please login as the user 请以用户身份登录 - + Server added successfully 增加服务器成功 @@ -431,180 +431,180 @@ Already installed containers were found on the server. All installed containers PageProtocolOpenVpnSettings - + OpenVPN settings OpenVPN 配置 - + VPN Addresses Subnet VPN子网掩码 - + Network protocol 网络协议 - + Port 端口 - + Auto-negotiate encryption 自定义加密方式 - + Hash - + SHA512 - + SHA384 - + SHA256 - + SHA3-512 - + SHA3-384 - + SHA3-256 - + whirlpool - + BLAKE2b512 - + BLAKE2s256 - + SHA1 - + Cipher - + AES-256-GCM - + AES-192-GCM - + AES-128-GCM - + AES-256-CBC - + AES-192-CBC - + AES-128-CBC - + ChaCha20-Poly1305 - + ARIA-256-CBC - + CAMELLIA-256-CBC - + none - + TLS auth TLS认证 - + Block DNS requests outside of VPN 阻止VPN外的DNS请求 - + Additional client configuration commands 附加客户端配置命令 - - + + Commands: 命令: - + Additional server configuration commands 附加服务器端配置命令 - + Remove OpenVPN 移除OpenVPN - + Remove OpenVpn from server? 从服务器移除OpenVPN吗? - + All users who you shared a connection with will no longer be able to connect to it. 使用此共享连接的所有用户,将无法再连接它。 @@ -613,17 +613,17 @@ Already installed containers were found on the server. All installed containers 与您共享连接的所有用户将无法再连接到此链接 - + Continue 继续 - + Cancel 取消 - + Save and Restart Amnezia 保存并重启Amnezia @@ -650,17 +650,17 @@ Already installed containers were found on the server. All installed containers %1 连接选项 - + Remove 移除 - + Remove %1 from server? 从服务器移除 %1 ? - + All users who you shared a connection with will no longer be able to connect to it. 使用此共享连接的所有用户,将无法再连接它。 @@ -673,12 +673,12 @@ Already installed containers were found on the server. All installed containers 与您共享连接的所有用户将无法再连接到此链接 - + Continue 继续 - + Cancel 取消 @@ -1801,22 +1801,22 @@ and will not be shared or disclosed to the Amnezia or any third parties PageSetupWizardInstalling - + Usually it takes no more than 5 minutes 通常不超过5分钟 - + The server has already been added to the application 服务器已添加到应用软件中 - + Amnezia has detected that your server is currently Amnezia 检测到您的服务器当前 - + busy installing other software. Amnezia installation 正安装其他软件。Amnezia安装 @@ -1829,12 +1829,12 @@ and will not be shared or disclosed to the Amnezia or any third parties 正安装其他软件。Amnezia安装 - + will pause until the server finishes installing other software 将暂停,直到其他软件安装完成。 - + Installing 安装中 @@ -1952,27 +1952,27 @@ and will not be shared or disclosed to the Amnezia or any third parties PageSetupWizardViewConfig - + New connection 新连接 - + Do not use connection code from public sources. It could be created to intercept your data. 请勿使用公共来源的连接码。它可以被创建来拦截您的数据。 - + Collapse content 折叠内容 - + Show content 显示内容 - + Connect 连接 diff --git a/client/ui/controllers/importController.cpp b/client/ui/controllers/importController.cpp index 08b662ec..bd924087 100644 --- a/client/ui/controllers/importController.cpp +++ b/client/ui/controllers/importController.cpp @@ -144,8 +144,6 @@ void ImportController::importConfig() if (credentials.isValid() || m_config.contains(config_key::containers)) { m_serversModel->addServer(m_config); - m_serversModel->setDefaultServerIndex(m_serversModel->getServersCount() - 1); - emit importFinished(); } else { qDebug() << "Failed to import profile"; diff --git a/client/ui/controllers/installController.cpp b/client/ui/controllers/installController.cpp index 8efe368b..2aa4e81b 100644 --- a/client/ui/controllers/installController.cpp +++ b/client/ui/controllers/installController.cpp @@ -163,7 +163,6 @@ void InstallController::installServer(DockerContainer container, QJsonObject &co server.insert(config_key::defaultContainer, ContainerProps::containerToString(container)); m_serversModel->addServer(server); - m_serversModel->setDefaultServerIndex(m_serversModel->getServersCount() - 1); emit installServerFinished(finishMessage); return; @@ -214,9 +213,6 @@ void InstallController::installContainer(DockerContainer container, QJsonObject "All installed containers have been added to the application"); } - if (ContainerProps::containerService(container) == ServiceType::Vpn) { - m_containersModel->setData(m_containersModel->index(container), true, ContainersModel::Roles::IsDefaultRole); - } emit installContainerFinished(finishMessage, ContainerProps::containerService(container) == ServiceType::Other); return; } @@ -509,7 +505,6 @@ void InstallController::addEmptyServer() server.insert(config_key::defaultContainer, ContainerProps::containerToString(DockerContainer::None)); m_serversModel->addServer(server); - m_serversModel->setDefaultServerIndex(m_serversModel->getServersCount() - 1); emit installServerFinished(tr("Server added successfully")); } diff --git a/client/ui/models/containers_model.cpp b/client/ui/models/containers_model.cpp index 0c99041e..780809c5 100644 --- a/client/ui/models/containers_model.cpp +++ b/client/ui/models/containers_model.cpp @@ -41,7 +41,7 @@ bool ContainersModel::setData(const QModelIndex &index, const QVariant &value, i // return container; case IsInstalledRole: // return m_settings->containers(m_currentlyProcessedServerIndex).contains(container); - case IsDefaultRole: { + case IsDefaultRole: { //todo remove m_settings->setDefaultContainer(m_currentlyProcessedServerIndex, container); m_defaultContainerIndex = container; emit defaultContainerChanged(); @@ -117,6 +117,13 @@ QString ContainersModel::getDefaultContainerName() return ContainerProps::containerHumanNames().value(m_defaultContainerIndex); } +void ContainersModel::setDefaultContainer(DockerContainer container) +{ + m_settings->setDefaultContainer(m_currentlyProcessedServerIndex, container); + m_defaultContainerIndex = container; + emit defaultContainerChanged(); +} + int ContainersModel::getCurrentlyProcessedContainerIndex() { return m_currentlyProcessedContainerIndex; diff --git a/client/ui/models/containers_model.h b/client/ui/models/containers_model.h index cc549bb3..4ba85749 100644 --- a/client/ui/models/containers_model.h +++ b/client/ui/models/containers_model.h @@ -46,6 +46,7 @@ public: public slots: DockerContainer getDefaultContainer(); QString getDefaultContainerName(); + void setDefaultContainer(DockerContainer container); void setCurrentlyProcessedServerIndex(const int index); diff --git a/client/ui/qml/Pages2/PageSetupWizardInstalling.qml b/client/ui/qml/Pages2/PageSetupWizardInstalling.qml index bd1fd7e6..50aad294 100644 --- a/client/ui/qml/Pages2/PageSetupWizardInstalling.qml +++ b/client/ui/qml/Pages2/PageSetupWizardInstalling.qml @@ -24,6 +24,10 @@ PageType { target: InstallController function onInstallContainerFinished(finishedMessage, isServiceInstall) { + if (!ConnectionController.isConnected && !isServiceInstall) { + ContainersModel.setDefaultContainer(ContainersModel.getCurrentlyProcessedContainerIndex) + } + PageController.goToStartPage() if (stackView.currentItem.objectName === PageController.getPagePath(PageEnum.PageHome)) { PageController.restorePageHomeState(true) @@ -41,6 +45,10 @@ PageType { } function onInstallServerFinished(finishedMessage) { + if (!ConnectionController.isConnected) { + ServersModel.setDefaultServerIndex(ServersModel.getServersCount() - 1); + } + PageController.goToStartPage() if (stackView.currentItem.objectName === PageController.getPagePath(PageEnum.PageSetupWizardStart)) { PageController.replaceStartPage() diff --git a/client/ui/qml/Pages2/PageSetupWizardViewConfig.qml b/client/ui/qml/Pages2/PageSetupWizardViewConfig.qml index 83132bd9..ac35651f 100644 --- a/client/ui/qml/Pages2/PageSetupWizardViewConfig.qml +++ b/client/ui/qml/Pages2/PageSetupWizardViewConfig.qml @@ -24,6 +24,10 @@ PageType { } function onImportFinished() { + if (ConnectionController.isConnected) { + ServersModel.setDefaultServerIndex(ServersModel.getServersCount() - 1); + } + PageController.goToStartPage() if (stackView.currentItem.objectName === PageController.getPagePath(PageEnum.PageSetupWizardStart)) { PageController.replaceStartPage()