Merge branch 'dev' into qt_migration
This commit is contained in:
commit
442e7eb015
127 changed files with 5657 additions and 1619 deletions
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include <QDesktopServices>
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
#include <QStandardPaths>
|
||||
|
||||
using namespace amnezia;
|
||||
|
|
@ -25,9 +26,9 @@ AppSettingsLogic::AppSettingsLogic(UiLogic *logic, QObject *parent):
|
|||
void AppSettingsLogic::onUpdatePage()
|
||||
{
|
||||
set_checkBoxAutostartChecked(Autostart::isAutostart());
|
||||
set_checkBoxAutoConnectChecked(m_settings.isAutoConnect());
|
||||
set_checkBoxStartMinimizedChecked(m_settings.isStartMinimized());
|
||||
set_checkBoxSaveLogsChecked(m_settings.isSaveLogs());
|
||||
set_checkBoxAutoConnectChecked(m_settings->isAutoConnect());
|
||||
set_checkBoxStartMinimizedChecked(m_settings->isStartMinimized());
|
||||
set_checkBoxSaveLogsChecked(m_settings->isSaveLogs());
|
||||
|
||||
QString ver = QString("%1: %2 (%3)")
|
||||
.arg(tr("Software version"))
|
||||
|
|
@ -46,17 +47,17 @@ void AppSettingsLogic::onCheckBoxAutostartToggled(bool checked)
|
|||
|
||||
void AppSettingsLogic::onCheckBoxAutoconnectToggled(bool checked)
|
||||
{
|
||||
m_settings.setAutoConnect(checked);
|
||||
m_settings->setAutoConnect(checked);
|
||||
}
|
||||
|
||||
void AppSettingsLogic::onCheckBoxStartMinimizedToggled(bool checked)
|
||||
{
|
||||
m_settings.setStartMinimized(checked);
|
||||
m_settings->setStartMinimized(checked);
|
||||
}
|
||||
|
||||
void AppSettingsLogic::onCheckBoxSaveLogsCheckedToggled(bool checked)
|
||||
{
|
||||
m_settings.setSaveLogs(checked);
|
||||
m_settings->setSaveLogs(checked);
|
||||
}
|
||||
|
||||
void AppSettingsLogic::onPushButtonOpenLogsClicked()
|
||||
|
|
@ -74,3 +75,32 @@ void AppSettingsLogic::onPushButtonClearLogsClicked()
|
|||
Debug::clearLogs();
|
||||
Debug::clearServiceLogs();
|
||||
}
|
||||
|
||||
void AppSettingsLogic::onPushButtonBackupAppConfigClicked()
|
||||
{
|
||||
uiLogic()->saveTextFile("Backup application config", "AmneziaVPN.backup", ".backup", m_settings->backupAppConfig());
|
||||
}
|
||||
|
||||
void AppSettingsLogic::onPushButtonRestoreAppConfigClicked()
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(nullptr, tr("Open backup"),
|
||||
QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), "*.backup");
|
||||
|
||||
if (fileName.isEmpty()) return;
|
||||
|
||||
QFile file(fileName);
|
||||
file.open(QIODevice::ReadOnly);
|
||||
QByteArray data = file.readAll();
|
||||
|
||||
bool ok = m_settings->restoreAppConfig(data);
|
||||
if (ok) {
|
||||
emit uiLogic()->goToPage(Page::Vpn);
|
||||
emit uiLogic()->setStartPage(Page::Vpn);
|
||||
}
|
||||
else {
|
||||
QMessageBox::warning(nullptr, APPLICATION_NAME,
|
||||
tr("Can't import config, file is corrupted."));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,10 @@ public:
|
|||
Q_INVOKABLE void onPushButtonExportLogsClicked();
|
||||
Q_INVOKABLE void onPushButtonClearLogsClicked();
|
||||
|
||||
Q_INVOKABLE void onPushButtonBackupAppConfigClicked();
|
||||
Q_INVOKABLE void onPushButtonRestoreAppConfigClicked();
|
||||
|
||||
|
||||
public:
|
||||
explicit AppSettingsLogic(UiLogic *uiLogic, QObject *parent = nullptr);
|
||||
~AppSettingsLogic() = default;
|
||||
|
|
|
|||
|
|
@ -12,28 +12,28 @@ GeneralSettingsLogic::GeneralSettingsLogic(UiLogic *logic, QObject *parent):
|
|||
|
||||
void GeneralSettingsLogic::onUpdatePage()
|
||||
{
|
||||
uiLogic()->selectedServerIndex = m_settings.defaultServerIndex();
|
||||
uiLogic()->selectedDockerContainer = m_settings.defaultContainer(m_settings.defaultServerIndex());
|
||||
uiLogic()->selectedServerIndex = m_settings->defaultServerIndex();
|
||||
uiLogic()->selectedDockerContainer = m_settings->defaultContainer(m_settings->defaultServerIndex());
|
||||
|
||||
set_pushButtonGeneralSettingsShareConnectionEnable(m_settings.haveAuthData(m_settings.defaultServerIndex()));
|
||||
set_pushButtonGeneralSettingsShareConnectionEnable(m_settings->haveAuthData(m_settings->defaultServerIndex()));
|
||||
}
|
||||
|
||||
void GeneralSettingsLogic::onPushButtonGeneralSettingsServerSettingsClicked()
|
||||
{
|
||||
uiLogic()->selectedServerIndex = m_settings.defaultServerIndex();
|
||||
uiLogic()->selectedDockerContainer = m_settings.defaultContainer(m_settings.defaultServerIndex());
|
||||
uiLogic()->selectedServerIndex = m_settings->defaultServerIndex();
|
||||
uiLogic()->selectedDockerContainer = m_settings->defaultContainer(m_settings->defaultServerIndex());
|
||||
|
||||
emit uiLogic()->goToPage(Page::ServerSettings);
|
||||
}
|
||||
|
||||
void GeneralSettingsLogic::onPushButtonGeneralSettingsShareConnectionClicked()
|
||||
{
|
||||
uiLogic()->selectedServerIndex = m_settings.defaultServerIndex();
|
||||
uiLogic()->selectedDockerContainer = m_settings.defaultContainer(uiLogic()->selectedServerIndex);
|
||||
uiLogic()->selectedServerIndex = m_settings->defaultServerIndex();
|
||||
uiLogic()->selectedDockerContainer = m_settings->defaultContainer(uiLogic()->selectedServerIndex);
|
||||
|
||||
qobject_cast<ProtocolsModel *>(uiLogic()->protocolsModel())->setSelectedServerIndex(uiLogic()->selectedServerIndex);
|
||||
qobject_cast<ProtocolsModel *>(uiLogic()->protocolsModel())->setSelectedDockerContainer(uiLogic()->selectedDockerContainer);
|
||||
|
||||
uiLogic()->shareConnectionLogic()->updateSharingPage(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer);
|
||||
uiLogic()->pageLogic<ShareConnectionLogic>()->updateSharingPage(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer);
|
||||
emit uiLogic()->goToPage(Page::ShareConnection);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "defines.h"
|
||||
#include "utilities.h"
|
||||
#include "settings.h"
|
||||
|
||||
NetworkSettingsLogic::NetworkSettingsLogic(UiLogic *logic, QObject *parent):
|
||||
PageLogicBase(logic, parent),
|
||||
|
|
@ -13,39 +14,39 @@ NetworkSettingsLogic::NetworkSettingsLogic(UiLogic *logic, QObject *parent):
|
|||
|
||||
void NetworkSettingsLogic::onUpdatePage()
|
||||
{
|
||||
set_checkBoxUseAmneziaDnsChecked(m_settings.useAmneziaDns());
|
||||
set_checkBoxUseAmneziaDnsChecked(m_settings->useAmneziaDns());
|
||||
|
||||
set_lineEditDns1Text(m_settings.primaryDns());
|
||||
set_lineEditDns2Text(m_settings.secondaryDns());
|
||||
set_lineEditDns1Text(m_settings->primaryDns());
|
||||
set_lineEditDns2Text(m_settings->secondaryDns());
|
||||
}
|
||||
|
||||
void NetworkSettingsLogic::onLineEditDns1EditFinished(const QString &text)
|
||||
{
|
||||
if (ipAddressRegex().match(text).hasMatch()) {
|
||||
m_settings.setPrimaryDns(text);
|
||||
m_settings->setPrimaryDns(text);
|
||||
}
|
||||
}
|
||||
|
||||
void NetworkSettingsLogic::onLineEditDns2EditFinished(const QString &text)
|
||||
{
|
||||
if (ipAddressRegex().match(text).hasMatch()) {
|
||||
m_settings.setSecondaryDns(text);
|
||||
m_settings->setSecondaryDns(text);
|
||||
}
|
||||
}
|
||||
|
||||
void NetworkSettingsLogic::onPushButtonResetDns1Clicked()
|
||||
{
|
||||
m_settings.setPrimaryDns(m_settings.cloudFlareNs1);
|
||||
m_settings->setPrimaryDns(m_settings->cloudFlareNs1);
|
||||
onUpdatePage();
|
||||
}
|
||||
|
||||
void NetworkSettingsLogic::onPushButtonResetDns2Clicked()
|
||||
{
|
||||
m_settings.setSecondaryDns(m_settings.cloudFlareNs2);
|
||||
m_settings->setSecondaryDns(m_settings->cloudFlareNs2);
|
||||
onUpdatePage();
|
||||
}
|
||||
|
||||
void NetworkSettingsLogic::onCheckBoxUseAmneziaDnsToggled(bool checked)
|
||||
{
|
||||
m_settings.setUseAmneziaDns(checked);
|
||||
m_settings->setUseAmneziaDns(checked);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
#include "PageLogicBase.h"
|
||||
|
||||
#include <QRegularExpression>
|
||||
|
||||
class UiLogic;
|
||||
|
||||
class NetworkSettingsLogic : public PageLogicBase
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
#define NEW_SERVER_PROTOCOLS_LOGIC_H
|
||||
|
||||
#include "PageLogicBase.h"
|
||||
#include "containers/containers_defs.h"
|
||||
|
||||
class UiLogic;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,17 @@
|
|||
#include "PageLogicBase.h"
|
||||
|
||||
#include "ui/uilogic.h"
|
||||
#include "settings.h"
|
||||
#include "configurators/vpn_configurator.h"
|
||||
|
||||
PageLogicBase::PageLogicBase(UiLogic *logic, QObject *parent):
|
||||
QObject(parent),
|
||||
m_pageEnabled{true},
|
||||
m_uiLogic(logic)
|
||||
{
|
||||
|
||||
m_settings = logic->m_settings;
|
||||
m_configurator = logic->m_configurator;
|
||||
m_serverController = logic->m_serverController;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +1,15 @@
|
|||
#ifndef PAGE_LOGIC_BASE_H
|
||||
#define PAGE_LOGIC_BASE_H
|
||||
|
||||
#include "settings.h"
|
||||
#include "../pages.h"
|
||||
#include "../property_helper.h"
|
||||
|
||||
using namespace amnezia;
|
||||
using namespace PageEnumNS;
|
||||
|
||||
class UiLogic;
|
||||
class Settings;
|
||||
class VpnConfigurator;
|
||||
class ServerController;
|
||||
|
||||
class PageLogicBase : public QObject
|
||||
{
|
||||
|
|
@ -22,10 +23,12 @@ public:
|
|||
Q_INVOKABLE virtual void onUpdatePage() {}
|
||||
|
||||
protected:
|
||||
UiLogic *m_uiLogic;
|
||||
UiLogic *uiLogic() const { return m_uiLogic; }
|
||||
|
||||
Settings m_settings;
|
||||
UiLogic *m_uiLogic;
|
||||
std::shared_ptr<Settings> m_settings;
|
||||
std::shared_ptr<VpnConfigurator> m_configurator;
|
||||
std::shared_ptr<ServerController> m_serverController;
|
||||
|
||||
signals:
|
||||
void updatePage();
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ void QrDecoderLogic::onDetectedQrCode(const QString &code)
|
|||
data.append(m_chunks.value(i));
|
||||
}
|
||||
|
||||
bool ok = uiLogic()->startPageLogic()->importConnectionFromQr(data);
|
||||
bool ok = uiLogic()->pageLogic<StartPageLogic>()->importConnectionFromQr(data);
|
||||
if (ok) {
|
||||
set_detectingEnabled(false);
|
||||
emit stopDecode();
|
||||
|
|
@ -67,7 +67,7 @@ void QrDecoderLogic::onDetectedQrCode(const QString &code)
|
|||
}
|
||||
}
|
||||
else {
|
||||
bool ok = uiLogic()->startPageLogic()->importConnectionFromQr(ba);
|
||||
bool ok = uiLogic()->pageLogic<StartPageLogic>()->importConnectionFromQr(ba);
|
||||
if (ok) {
|
||||
set_detectingEnabled(false);
|
||||
emit stopDecode();
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@
|
|||
|
||||
#include <functional>
|
||||
#include "PageLogicBase.h"
|
||||
#include "core/defs.h"
|
||||
|
||||
using namespace amnezia;
|
||||
|
||||
class UiLogic;
|
||||
|
||||
|
|
|
|||
|
|
@ -36,64 +36,64 @@ void ServerContainersLogic::onPushButtonProtoSettingsClicked(DockerContainer c,
|
|||
{
|
||||
qDebug()<< "ServerContainersLogic::onPushButtonProtoSettingsClicked" << c << p;
|
||||
uiLogic()->selectedDockerContainer = c;
|
||||
uiLogic()->protocolLogic(p)->updateProtocolPage(m_settings.protocolConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer, p),
|
||||
uiLogic()->protocolLogic(p)->updateProtocolPage(m_settings->protocolConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer, p),
|
||||
uiLogic()->selectedDockerContainer,
|
||||
m_settings.haveAuthData(uiLogic()->selectedServerIndex));
|
||||
m_settings->haveAuthData(uiLogic()->selectedServerIndex));
|
||||
|
||||
emit uiLogic()->goToProtocolPage(p);
|
||||
}
|
||||
|
||||
void ServerContainersLogic::onPushButtonDefaultClicked(DockerContainer c)
|
||||
{
|
||||
if (m_settings.defaultContainer(uiLogic()->selectedServerIndex) == c) return;
|
||||
if (m_settings->defaultContainer(uiLogic()->selectedServerIndex) == c) return;
|
||||
|
||||
m_settings.setDefaultContainer(uiLogic()->selectedServerIndex, c);
|
||||
m_settings->setDefaultContainer(uiLogic()->selectedServerIndex, c);
|
||||
uiLogic()->onUpdateAllPages();
|
||||
|
||||
if (uiLogic()->selectedServerIndex != m_settings.defaultServerIndex()) return;
|
||||
if (uiLogic()->selectedServerIndex != m_settings->defaultServerIndex()) return;
|
||||
if (!uiLogic()->m_vpnConnection) return;
|
||||
if (!uiLogic()->m_vpnConnection->isConnected()) return;
|
||||
|
||||
uiLogic()->vpnLogic()->onDisconnect();
|
||||
uiLogic()->vpnLogic()->onConnect();
|
||||
uiLogic()->pageLogic<VpnLogic>()->onDisconnect();
|
||||
uiLogic()->pageLogic<VpnLogic>()->onConnect();
|
||||
}
|
||||
|
||||
void ServerContainersLogic::onPushButtonShareClicked(DockerContainer c)
|
||||
{
|
||||
uiLogic()->shareConnectionLogic()->updateSharingPage(uiLogic()->selectedServerIndex, c);
|
||||
uiLogic()->pageLogic<ShareConnectionLogic>()->updateSharingPage(uiLogic()->selectedServerIndex, c);
|
||||
emit uiLogic()->goToPage(Page::ShareConnection);
|
||||
}
|
||||
|
||||
void ServerContainersLogic::onPushButtonRemoveClicked(DockerContainer container)
|
||||
{
|
||||
//buttonSetEnabledFunc(false);
|
||||
ErrorCode e = ServerController::removeContainer(m_settings.serverCredentials(uiLogic()->selectedServerIndex), container);
|
||||
m_settings.removeContainerConfig(uiLogic()->selectedServerIndex, container);
|
||||
ErrorCode e = m_serverController->removeContainer(m_settings->serverCredentials(uiLogic()->selectedServerIndex), container);
|
||||
m_settings->removeContainerConfig(uiLogic()->selectedServerIndex, container);
|
||||
//buttonSetEnabledFunc(true);
|
||||
|
||||
if (m_settings.defaultContainer(uiLogic()->selectedServerIndex) == container) {
|
||||
const auto &c = m_settings.containers(uiLogic()->selectedServerIndex);
|
||||
if (c.isEmpty()) m_settings.setDefaultContainer(uiLogic()->selectedServerIndex, DockerContainer::None);
|
||||
else m_settings.setDefaultContainer(uiLogic()->selectedServerIndex, c.keys().first());
|
||||
if (m_settings->defaultContainer(uiLogic()->selectedServerIndex) == container) {
|
||||
const auto &c = m_settings->containers(uiLogic()->selectedServerIndex);
|
||||
if (c.isEmpty()) m_settings->setDefaultContainer(uiLogic()->selectedServerIndex, DockerContainer::None);
|
||||
else m_settings->setDefaultContainer(uiLogic()->selectedServerIndex, c.keys().first());
|
||||
}
|
||||
uiLogic()->onUpdateAllPages();
|
||||
}
|
||||
|
||||
void ServerContainersLogic::onPushButtonContinueClicked(DockerContainer c, int port, TransportProto tp)
|
||||
{
|
||||
QJsonObject config = ServerController::createContainerInitialConfig(c, port, tp);
|
||||
QJsonObject config = m_serverController->createContainerInitialConfig(c, port, tp);
|
||||
|
||||
emit uiLogic()->goToPage(Page::ServerConfiguringProgress);
|
||||
qApp->processEvents();
|
||||
|
||||
ErrorCode e = uiLogic()->serverConfiguringProgressLogic()->doInstallAction([this, c, &config](){
|
||||
return ServerController::setupContainer(m_settings.serverCredentials(uiLogic()->selectedServerIndex), c, config);
|
||||
ErrorCode e = uiLogic()->pageLogic<ServerConfiguringProgressLogic>()->doInstallAction([this, c, &config](){
|
||||
return m_serverController->setupContainer(m_settings->serverCredentials(uiLogic()->selectedServerIndex), c, config);
|
||||
});
|
||||
|
||||
if (!e) {
|
||||
m_settings.setContainerConfig(uiLogic()->selectedServerIndex, c, config);
|
||||
m_settings->setContainerConfig(uiLogic()->selectedServerIndex, c, config);
|
||||
if (ContainerProps::containerService(c) == ServiceType::Vpn) {
|
||||
m_settings.setDefaultContainer(uiLogic()->selectedServerIndex, c);
|
||||
m_settings->setDefaultContainer(uiLogic()->selectedServerIndex, c);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
#define SERVER_CONTAINERS_LOGIC_H
|
||||
|
||||
#include "PageLogicBase.h"
|
||||
#include "containers/containers_defs.h"
|
||||
|
||||
class UiLogic;
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ ServerListLogic::ServerListLogic(UiLogic *logic, QObject *parent):
|
|||
|
||||
void ServerListLogic::onServerListPushbuttonDefaultClicked(int index)
|
||||
{
|
||||
m_settings.setDefaultServer(index);
|
||||
m_settings->setDefaultServer(index);
|
||||
uiLogic()->onUpdateAllPages();
|
||||
}
|
||||
|
||||
|
|
@ -25,8 +25,8 @@ void ServerListLogic::onServerListPushbuttonSettingsClicked(int index)
|
|||
|
||||
void ServerListLogic::onUpdatePage()
|
||||
{
|
||||
const QJsonArray &servers = m_settings.serversArray();
|
||||
int defaultServer = m_settings.defaultServerIndex();
|
||||
const QJsonArray &servers = m_settings->serversArray();
|
||||
int defaultServer = m_settings->defaultServerIndex();
|
||||
std::vector<ServerModelContent> serverListContent;
|
||||
for(int i = 0; i < servers.size(); i++) {
|
||||
ServerModelContent c;
|
||||
|
|
|
|||
|
|
@ -10,6 +10,12 @@
|
|||
#include <core/servercontroller.h>
|
||||
#include <QTimer>
|
||||
|
||||
#if defined(Q_OS_ANDROID)
|
||||
#include <QAndroidJniObject>
|
||||
#include <QAndroidJniEnvironment>
|
||||
#include <QtAndroid>
|
||||
#endif
|
||||
|
||||
ServerSettingsLogic::ServerSettingsLogic(UiLogic *logic, QObject *parent):
|
||||
PageLogicBase(logic, parent),
|
||||
m_labelWaitInfoVisible{true},
|
||||
|
|
@ -26,10 +32,10 @@ void ServerSettingsLogic::onUpdatePage()
|
|||
{
|
||||
set_labelWaitInfoVisible(false);
|
||||
set_labelWaitInfoText("");
|
||||
set_pushButtonClearVisible(m_settings.haveAuthData(uiLogic()->selectedServerIndex));
|
||||
set_pushButtonClearClientCacheVisible(m_settings.haveAuthData(uiLogic()->selectedServerIndex));
|
||||
set_pushButtonShareFullVisible(m_settings.haveAuthData(uiLogic()->selectedServerIndex));
|
||||
const QJsonObject &server = m_settings.server(uiLogic()->selectedServerIndex);
|
||||
set_pushButtonClearVisible(m_settings->haveAuthData(uiLogic()->selectedServerIndex));
|
||||
set_pushButtonClearClientCacheVisible(m_settings->haveAuthData(uiLogic()->selectedServerIndex));
|
||||
set_pushButtonShareFullVisible(m_settings->haveAuthData(uiLogic()->selectedServerIndex));
|
||||
const QJsonObject &server = m_settings->server(uiLogic()->selectedServerIndex);
|
||||
const QString &port = server.value(config_key::port).toString();
|
||||
set_labelServerText(QString("%1@%2%3%4")
|
||||
.arg(server.value(config_key::userName).toString())
|
||||
|
|
@ -38,7 +44,7 @@ void ServerSettingsLogic::onUpdatePage()
|
|||
.arg(port));
|
||||
set_lineEditDescriptionText(server.value(config_key::description).toString());
|
||||
|
||||
DockerContainer selectedContainer = m_settings.defaultContainer(uiLogic()->selectedServerIndex);
|
||||
DockerContainer selectedContainer = m_settings->defaultContainer(uiLogic()->selectedServerIndex);
|
||||
QString selectedContainerName = ContainerProps::containerHumanNames().value(selectedContainer);
|
||||
set_labelCurrentVpnProtocolText(tr("Service: ") + selectedContainerName);
|
||||
}
|
||||
|
|
@ -48,14 +54,14 @@ void ServerSettingsLogic::onPushButtonClearServer()
|
|||
set_pageEnabled(false);
|
||||
set_pushButtonClearText(tr("Uninstalling Amnezia software..."));
|
||||
|
||||
if (m_settings.defaultServerIndex() == uiLogic()->selectedServerIndex) {
|
||||
uiLogic()->vpnLogic()->onDisconnect();
|
||||
if (m_settings->defaultServerIndex() == uiLogic()->selectedServerIndex) {
|
||||
uiLogic()->pageLogic<VpnLogic>()->onDisconnect();
|
||||
}
|
||||
|
||||
ErrorCode e = ServerController::removeAllContainers(m_settings.serverCredentials(uiLogic()->selectedServerIndex));
|
||||
ServerController::disconnectFromHost(m_settings.serverCredentials(uiLogic()->selectedServerIndex));
|
||||
ErrorCode e = m_serverController->removeAllContainers(m_settings->serverCredentials(uiLogic()->selectedServerIndex));
|
||||
m_serverController->disconnectFromHost(m_settings->serverCredentials(uiLogic()->selectedServerIndex));
|
||||
if (e) {
|
||||
uiLogic()->setDialogConnectErrorText(
|
||||
uiLogic()->set_dialogConnectErrorText(
|
||||
tr("Error occurred while configuring server.") + "\n" +
|
||||
errorString(e) + "\n" +
|
||||
tr("See logs for details."));
|
||||
|
|
@ -66,8 +72,8 @@ void ServerSettingsLogic::onPushButtonClearServer()
|
|||
set_labelWaitInfoText(tr("Amnezia server successfully uninstalled"));
|
||||
}
|
||||
|
||||
m_settings.setContainers(uiLogic()->selectedServerIndex, {});
|
||||
m_settings.setDefaultContainer(uiLogic()->selectedServerIndex, DockerContainer::None);
|
||||
m_settings->setContainers(uiLogic()->selectedServerIndex, {});
|
||||
m_settings->setDefaultContainer(uiLogic()->selectedServerIndex, DockerContainer::None);
|
||||
|
||||
set_pageEnabled(true);
|
||||
set_pushButtonClearText(tr("Clear server from Amnezia software"));
|
||||
|
|
@ -75,27 +81,27 @@ void ServerSettingsLogic::onPushButtonClearServer()
|
|||
|
||||
void ServerSettingsLogic::onPushButtonForgetServer()
|
||||
{
|
||||
if (m_settings.defaultServerIndex() == uiLogic()->selectedServerIndex && uiLogic()->m_vpnConnection->isConnected()) {
|
||||
uiLogic()->vpnLogic()->onDisconnect();
|
||||
if (m_settings->defaultServerIndex() == uiLogic()->selectedServerIndex && uiLogic()->m_vpnConnection->isConnected()) {
|
||||
uiLogic()->pageLogic<VpnLogic>()->onDisconnect();
|
||||
}
|
||||
m_settings.removeServer(uiLogic()->selectedServerIndex);
|
||||
m_settings->removeServer(uiLogic()->selectedServerIndex);
|
||||
|
||||
if (m_settings.defaultServerIndex() == uiLogic()->selectedServerIndex) {
|
||||
m_settings.setDefaultServer(0);
|
||||
if (m_settings->defaultServerIndex() == uiLogic()->selectedServerIndex) {
|
||||
m_settings->setDefaultServer(0);
|
||||
}
|
||||
else if (m_settings.defaultServerIndex() > uiLogic()->selectedServerIndex) {
|
||||
m_settings.setDefaultServer(m_settings.defaultServerIndex() - 1);
|
||||
else if (m_settings->defaultServerIndex() > uiLogic()->selectedServerIndex) {
|
||||
m_settings->setDefaultServer(m_settings->defaultServerIndex() - 1);
|
||||
}
|
||||
|
||||
if (m_settings.serversCount() == 0) {
|
||||
m_settings.setDefaultServer(-1);
|
||||
if (m_settings->serversCount() == 0) {
|
||||
m_settings->setDefaultServer(-1);
|
||||
}
|
||||
|
||||
|
||||
uiLogic()->selectedServerIndex = -1;
|
||||
uiLogic()->onUpdateAllPages();
|
||||
|
||||
if (m_settings.serversCount() == 0) {
|
||||
if (m_settings->serversCount() == 0) {
|
||||
uiLogic()->setStartPage(Page::Start);
|
||||
}
|
||||
else {
|
||||
|
|
@ -107,9 +113,9 @@ void ServerSettingsLogic::onPushButtonClearClientCacheClicked()
|
|||
{
|
||||
set_pushButtonClearClientCacheText(tr("Cache cleared"));
|
||||
|
||||
const auto &containers = m_settings.containers(uiLogic()->selectedServerIndex);
|
||||
const auto &containers = m_settings->containers(uiLogic()->selectedServerIndex);
|
||||
for (DockerContainer container: containers.keys()) {
|
||||
m_settings.clearLastConnectionConfig(uiLogic()->selectedServerIndex, container);
|
||||
m_settings->clearLastConnectionConfig(uiLogic()->selectedServerIndex, container);
|
||||
}
|
||||
|
||||
QTimer::singleShot(3000, this, [this]() {
|
||||
|
|
@ -120,14 +126,47 @@ void ServerSettingsLogic::onPushButtonClearClientCacheClicked()
|
|||
void ServerSettingsLogic::onLineEditDescriptionEditingFinished()
|
||||
{
|
||||
const QString &newText = lineEditDescriptionText();
|
||||
QJsonObject server = m_settings.server(uiLogic()->selectedServerIndex);
|
||||
QJsonObject server = m_settings->server(uiLogic()->selectedServerIndex);
|
||||
server.insert(config_key::description, newText);
|
||||
m_settings.editServer(uiLogic()->selectedServerIndex, server);
|
||||
m_settings->editServer(uiLogic()->selectedServerIndex, server);
|
||||
uiLogic()->onUpdateAllPages();
|
||||
}
|
||||
|
||||
#if defined(Q_OS_ANDROID)
|
||||
/* Auth result handler for Android */
|
||||
void authResultReceiver::handleActivityResult(int receiverRequestCode, int resultCode, const QAndroidJniObject &data)
|
||||
{
|
||||
qDebug() << "receiverRequestCode" << receiverRequestCode << "resultCode" << resultCode;
|
||||
|
||||
if (resultCode == -1) { //ResultOK
|
||||
uiLogic()->pageLogic<ShareConnectionLogic>()->updateSharingPage(m_serverIndex, DockerContainer::None);
|
||||
emit uiLogic()->goToShareProtocolPage(Proto::Any);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void ServerSettingsLogic::onPushButtonShareFullClicked()
|
||||
{
|
||||
uiLogic()->shareConnectionLogic()->updateSharingPage(uiLogic()->selectedServerIndex, DockerContainer::None);
|
||||
#if defined(Q_OS_ANDROID)
|
||||
/* We use builtin keyguard for ssh key export protection on Android */
|
||||
auto appContext = QtAndroid::androidActivity().callObjectMethod(
|
||||
"getApplicationContext", "()Landroid/content/Context;");
|
||||
if (appContext.isValid()) {
|
||||
QAndroidActivityResultReceiver *receiver = new authResultReceiver(uiLogic(), uiLogic()->selectedServerIndex);
|
||||
auto intent = QAndroidJniObject::callStaticObjectMethod(
|
||||
"org/amnezia/vpn/AuthHelper", "getAuthIntent",
|
||||
"(Landroid/content/Context;)Landroid/content/Intent;", appContext.object());
|
||||
if (intent.isValid()) {
|
||||
if (intent.object<jobject>() != nullptr) {
|
||||
QtAndroid::startActivity(intent.object<jobject>(), 1, receiver);
|
||||
}
|
||||
} else {
|
||||
uiLogic()->pageLogic<ShareConnectionLogic>()->updateSharingPage(uiLogic()->selectedServerIndex, DockerContainer::None);
|
||||
emit uiLogic()->goToShareProtocolPage(Proto::Any);
|
||||
}
|
||||
}
|
||||
#else
|
||||
uiLogic()->pageLogic<ShareConnectionLogic>()->updateSharingPage(uiLogic()->selectedServerIndex, DockerContainer::None);
|
||||
emit uiLogic()->goToShareProtocolPage(Proto::Any);
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,10 @@
|
|||
|
||||
#include "PageLogicBase.h"
|
||||
|
||||
#if defined(Q_OS_ANDROID)
|
||||
#include <QAndroidActivityResultReceiver>
|
||||
#endif
|
||||
|
||||
class UiLogic;
|
||||
|
||||
class ServerSettingsLogic : public PageLogicBase
|
||||
|
|
@ -34,4 +38,25 @@ public:
|
|||
~ServerSettingsLogic() = default;
|
||||
|
||||
};
|
||||
|
||||
#if defined(Q_OS_ANDROID)
|
||||
/* Auth result handler for Android */
|
||||
class authResultReceiver final : public PageLogicBase, public QAndroidActivityResultReceiver
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
authResultReceiver(UiLogic *uiLogic, int serverIndex , QObject *parent = nullptr) : PageLogicBase(uiLogic, parent) {
|
||||
m_serverIndex = serverIndex;
|
||||
}
|
||||
~authResultReceiver() {}
|
||||
|
||||
public:
|
||||
void handleActivityResult(int receiverRequestCode, int resultCode, const QAndroidJniObject &data) override;
|
||||
|
||||
private:
|
||||
int m_serverIndex;
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif // SERVER_SETTINGS_LOGIC_H
|
||||
|
|
|
|||
|
|
@ -1,12 +1,10 @@
|
|||
#include <QBuffer>
|
||||
#include <QImage>
|
||||
#include <QDataStream>
|
||||
//#include <QZXing>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "QZXing.h"
|
||||
#include "QZXingImageProvider.h"
|
||||
//#include "QZXingFilter.h"
|
||||
|
||||
#include "qrcodegen.hpp"
|
||||
|
||||
#include "ShareConnectionLogic.h"
|
||||
|
||||
|
|
@ -21,6 +19,7 @@
|
|||
#include "defines.h"
|
||||
#include "core/defs.h"
|
||||
#include "core/errorstrings.h"
|
||||
#include "core/servercontroller.h"
|
||||
#include <functional>
|
||||
|
||||
#include "../uilogic.h"
|
||||
|
|
@ -29,6 +28,8 @@
|
|||
#include <math.h>
|
||||
#endif
|
||||
|
||||
using namespace qrcodegen;
|
||||
|
||||
ShareConnectionLogic::ShareConnectionLogic(UiLogic *logic, QObject *parent):
|
||||
PageLogicBase(logic, parent),
|
||||
m_textEditShareOpenVpnCodeText{},
|
||||
|
|
@ -73,19 +74,19 @@ void ShareConnectionLogic::onPushButtonShareAmneziaGenerateClicked()
|
|||
|
||||
// Full access
|
||||
if (shareFullAccess()) {
|
||||
serverConfig = m_settings.server(serverIndex);
|
||||
serverConfig = m_settings->server(serverIndex);
|
||||
}
|
||||
// Container share
|
||||
else {
|
||||
ServerCredentials credentials = m_settings.serverCredentials(serverIndex);
|
||||
QJsonObject containerConfig = m_settings.containerConfig(serverIndex, container);
|
||||
ServerCredentials credentials = m_settings->serverCredentials(serverIndex);
|
||||
QJsonObject containerConfig = m_settings->containerConfig(serverIndex, container);
|
||||
containerConfig.insert(config_key::container, ContainerProps::containerToString(container));
|
||||
|
||||
ErrorCode e = ErrorCode::NoError;
|
||||
for (Proto p: ContainerProps::protocolsForContainer(container)) {
|
||||
QJsonObject protoConfig = m_settings.protocolConfig(serverIndex, container, p);
|
||||
QJsonObject protoConfig = m_settings->protocolConfig(serverIndex, container, p);
|
||||
|
||||
QString cfg = VpnConfigurator::genVpnProtocolConfig(credentials, container, containerConfig, p, &e);
|
||||
QString cfg = m_configurator->genVpnProtocolConfig(credentials, container, containerConfig, p, &e);
|
||||
if (e) {
|
||||
cfg = "Error generating config";
|
||||
break;
|
||||
|
|
@ -96,14 +97,14 @@ void ShareConnectionLogic::onPushButtonShareAmneziaGenerateClicked()
|
|||
|
||||
QByteArray ba;
|
||||
if (!e) {
|
||||
serverConfig = m_settings.server(serverIndex);
|
||||
serverConfig = m_settings->server(serverIndex);
|
||||
serverConfig.remove(config_key::userName);
|
||||
serverConfig.remove(config_key::password);
|
||||
serverConfig.remove(config_key::port);
|
||||
serverConfig.insert(config_key::containers, QJsonArray {containerConfig});
|
||||
serverConfig.insert(config_key::defaultContainer, ContainerProps::containerToString(container));
|
||||
|
||||
auto dns = VpnConfigurator::getDnsForConfig(serverIndex);
|
||||
auto dns = m_configurator->getDnsForConfig(serverIndex);
|
||||
serverConfig.insert(config_key::dns1, dns.first);
|
||||
serverConfig.insert(config_key::dns2, dns.second);
|
||||
|
||||
|
|
@ -129,13 +130,13 @@ void ShareConnectionLogic::onPushButtonShareOpenVpnGenerateClicked()
|
|||
{
|
||||
int serverIndex = uiLogic()->selectedServerIndex;
|
||||
DockerContainer container = uiLogic()->selectedDockerContainer;
|
||||
ServerCredentials credentials = m_settings.serverCredentials(serverIndex);
|
||||
ServerCredentials credentials = m_settings->serverCredentials(serverIndex);
|
||||
|
||||
const QJsonObject &containerConfig = m_settings.containerConfig(serverIndex, container);
|
||||
const QJsonObject &containerConfig = m_settings->containerConfig(serverIndex, container);
|
||||
|
||||
ErrorCode e = ErrorCode::NoError;
|
||||
QString cfg = OpenVpnConfigurator::genOpenVpnConfig(credentials, container, containerConfig, &e);
|
||||
cfg = VpnConfigurator::processConfigWithExportSettings(serverIndex, container, Proto::OpenVpn, cfg);
|
||||
QString cfg = m_configurator->openVpnConfigurator->genOpenVpnConfig(credentials, container, containerConfig, &e);
|
||||
cfg = m_configurator->processConfigWithExportSettings(serverIndex, container, Proto::OpenVpn, cfg);
|
||||
|
||||
set_textEditShareOpenVpnCodeText(QJsonDocument::fromJson(cfg.toUtf8()).object()[config_key::config].toString());
|
||||
}
|
||||
|
|
@ -144,16 +145,16 @@ void ShareConnectionLogic::onPushButtonShareShadowSocksGenerateClicked()
|
|||
{
|
||||
int serverIndex = uiLogic()->selectedServerIndex;
|
||||
DockerContainer container = uiLogic()->selectedDockerContainer;
|
||||
ServerCredentials credentials = m_settings.serverCredentials(serverIndex);
|
||||
ServerCredentials credentials = m_settings->serverCredentials(serverIndex);
|
||||
|
||||
QJsonObject protoConfig = m_settings.protocolConfig(serverIndex, container, Proto::ShadowSocks);
|
||||
QJsonObject protoConfig = m_settings->protocolConfig(serverIndex, container, Proto::ShadowSocks);
|
||||
QString cfg = protoConfig.value(config_key::last_config).toString();
|
||||
|
||||
if (cfg.isEmpty()) {
|
||||
const QJsonObject &containerConfig = m_settings.containerConfig(serverIndex, container);
|
||||
const QJsonObject &containerConfig = m_settings->containerConfig(serverIndex, container);
|
||||
|
||||
ErrorCode e = ErrorCode::NoError;
|
||||
cfg = ShadowSocksConfigurator::genShadowSocksConfig(credentials, container, containerConfig, &e);
|
||||
cfg = m_configurator->shadowSocksConfigurator->genShadowSocksConfig(credentials, container, containerConfig, &e);
|
||||
}
|
||||
|
||||
QJsonObject ssConfig = QJsonDocument::fromJson(cfg.toUtf8()).object();
|
||||
|
|
@ -167,8 +168,10 @@ void ShareConnectionLogic::onPushButtonShareShadowSocksGenerateClicked()
|
|||
ssString = "ss://" + ssString.toUtf8().toBase64();
|
||||
set_lineEditShareShadowSocksStringText(ssString);
|
||||
|
||||
QImage qr = QZXing::encodeData(ssString.toUtf8(), QZXing::EncoderFormat_QR_CODE, QSize(512,512), QZXing::EncodeErrorCorrectionLevel_L);
|
||||
set_shareShadowSocksQrCodeText(imageToBase64(qr));
|
||||
QrCode qr = QrCode::encodeText(ssString.toUtf8(), QrCode::Ecc::LOW);
|
||||
QString svg = QString::fromStdString(toSvgString(qr, 0));
|
||||
|
||||
set_shareShadowSocksQrCodeText(svgToBase64(svg));
|
||||
|
||||
QString humanString = QString("Server: %3\n"
|
||||
"Port: %4\n"
|
||||
|
|
@ -186,16 +189,16 @@ void ShareConnectionLogic::onPushButtonShareCloakGenerateClicked()
|
|||
{
|
||||
int serverIndex = uiLogic()->selectedServerIndex;
|
||||
DockerContainer container = uiLogic()->selectedDockerContainer;
|
||||
ServerCredentials credentials = m_settings.serverCredentials(serverIndex);
|
||||
ServerCredentials credentials = m_settings->serverCredentials(serverIndex);
|
||||
|
||||
QJsonObject protoConfig = m_settings.protocolConfig(serverIndex, container, Proto::Cloak);
|
||||
QJsonObject protoConfig = m_settings->protocolConfig(serverIndex, container, Proto::Cloak);
|
||||
QString cfg = protoConfig.value(config_key::last_config).toString();
|
||||
|
||||
if (cfg.isEmpty()) {
|
||||
const QJsonObject &containerConfig = m_settings.containerConfig(serverIndex, container);
|
||||
const QJsonObject &containerConfig = m_settings->containerConfig(serverIndex, container);
|
||||
|
||||
ErrorCode e = ErrorCode::NoError;
|
||||
cfg = CloakConfigurator::genCloakConfig(credentials, container, containerConfig, &e);
|
||||
cfg = m_configurator->cloakConfigurator->genCloakConfig(credentials, container, containerConfig, &e);
|
||||
}
|
||||
|
||||
QJsonObject cloakConfig = QJsonDocument::fromJson(cfg.toUtf8()).object();
|
||||
|
|
@ -209,48 +212,47 @@ void ShareConnectionLogic::onPushButtonShareWireGuardGenerateClicked()
|
|||
{
|
||||
int serverIndex = uiLogic()->selectedServerIndex;
|
||||
DockerContainer container = uiLogic()->selectedDockerContainer;
|
||||
ServerCredentials credentials = m_settings.serverCredentials(serverIndex);
|
||||
ServerCredentials credentials = m_settings->serverCredentials(serverIndex);
|
||||
|
||||
const QJsonObject &containerConfig = m_settings.containerConfig(serverIndex, container);
|
||||
const QJsonObject &containerConfig = m_settings->containerConfig(serverIndex, container);
|
||||
|
||||
ErrorCode e = ErrorCode::NoError;
|
||||
QString cfg = WireguardConfigurator::genWireguardConfig(credentials, container, containerConfig, &e);
|
||||
QString cfg = m_configurator->wireguardConfigurator->genWireguardConfig(credentials, container, containerConfig, &e);
|
||||
if (e) {
|
||||
QMessageBox::warning(nullptr, APPLICATION_NAME,
|
||||
tr("Error occurred while configuring server.") + "\n" +
|
||||
errorString(e));
|
||||
return;
|
||||
}
|
||||
cfg = VpnConfigurator::processConfigWithExportSettings(serverIndex, container, Proto::WireGuard, cfg);
|
||||
cfg = m_configurator->processConfigWithExportSettings(serverIndex, container, Proto::WireGuard, cfg);
|
||||
cfg = QJsonDocument::fromJson(cfg.toUtf8()).object()[config_key::config].toString();
|
||||
|
||||
set_textEditShareWireGuardCodeText(cfg);
|
||||
|
||||
QImage qr = QZXing::encodeData(cfg.toUtf8(), QZXing::EncoderFormat_QR_CODE, QSize(512,512), QZXing::EncodeErrorCorrectionLevel_L);
|
||||
QrCode qr = QrCode::encodeText(cfg.toUtf8(), QrCode::Ecc::LOW);
|
||||
QString svg = QString::fromStdString(toSvgString(qr, 0));
|
||||
|
||||
set_shareWireGuardQrCodeText(imageToBase64(qr));
|
||||
set_shareWireGuardQrCodeText(svgToBase64(svg));
|
||||
}
|
||||
|
||||
void ShareConnectionLogic::onPushButtonShareIkev2GenerateClicked()
|
||||
{
|
||||
int serverIndex = uiLogic()->selectedServerIndex;
|
||||
DockerContainer container = uiLogic()->selectedDockerContainer;
|
||||
ServerCredentials credentials = m_settings.serverCredentials(serverIndex);
|
||||
ServerCredentials credentials = m_settings->serverCredentials(serverIndex);
|
||||
|
||||
//const QJsonObject &containerConfig = m_settings.containerConfig(serverIndex, container);
|
||||
Ikev2Configurator::ConnectionData connData = m_configurator->ikev2Configurator->prepareIkev2Config(credentials, container);
|
||||
|
||||
Ikev2Configurator::ConnectionData connData = Ikev2Configurator::prepareIkev2Config(credentials, container);
|
||||
|
||||
QString cfg = Ikev2Configurator::genIkev2Config(connData);
|
||||
cfg = VpnConfigurator::processConfigWithExportSettings(serverIndex, container, Proto::Ikev2, cfg);
|
||||
QString cfg = m_configurator->ikev2Configurator->genIkev2Config(connData);
|
||||
cfg = m_configurator->processConfigWithExportSettings(serverIndex, container, Proto::Ikev2, cfg);
|
||||
cfg = QJsonDocument::fromJson(cfg.toUtf8()).object()[config_key::cert].toString();
|
||||
|
||||
set_textEditShareIkev2CertText(cfg);
|
||||
|
||||
QString mobileCfg = Ikev2Configurator::genMobileConfig(connData);
|
||||
QString mobileCfg = m_configurator->ikev2Configurator->genMobileConfig(connData);
|
||||
set_textEditShareIkev2MobileConfigText(mobileCfg);
|
||||
|
||||
QString strongSwanCfg = Ikev2Configurator::genStrongSwanConfig(connData);
|
||||
QString strongSwanCfg = m_configurator->ikev2Configurator->genStrongSwanConfig(connData);
|
||||
set_textEditShareIkev2StrongSwanConfigText(strongSwanCfg);
|
||||
|
||||
}
|
||||
|
|
@ -268,7 +270,7 @@ void ShareConnectionLogic::updateSharingPage(int serverIndex, DockerContainer co
|
|||
|
||||
QList<QString> ShareConnectionLogic::genQrCodeImageSeries(const QByteArray &data)
|
||||
{
|
||||
double k = 1500;
|
||||
double k = 850;
|
||||
|
||||
quint8 chunksCount = std::ceil(data.size() / k);
|
||||
QList<QString> chunks;
|
||||
|
|
@ -279,18 +281,15 @@ QList<QString> ShareConnectionLogic::genQrCodeImageSeries(const QByteArray &data
|
|||
|
||||
QByteArray ba = chunk.toBase64(QByteArray::Base64UrlEncoding | QByteArray::OmitTrailingEquals);
|
||||
|
||||
QImage qr = QZXing::encodeData(ba, QZXing::EncoderFormat_QR_CODE, QSize(512,512), QZXing::EncodeErrorCorrectionLevel_L);
|
||||
chunks.append(imageToBase64(qr));
|
||||
QrCode qr = QrCode::encodeText(ba, QrCode::Ecc::LOW);
|
||||
QString svg = QString::fromStdString(toSvgString(qr, 0));
|
||||
chunks.append(svgToBase64(svg));
|
||||
}
|
||||
|
||||
return chunks;
|
||||
}
|
||||
|
||||
QString ShareConnectionLogic::imageToBase64(const QImage &image)
|
||||
QString ShareConnectionLogic::svgToBase64(const QString &image)
|
||||
{
|
||||
QByteArray ba;
|
||||
QBuffer bu(&ba);
|
||||
bu.open(QIODevice::WriteOnly);
|
||||
image.save(&bu, "PNG");
|
||||
return "data:image/png;base64," + QString::fromLatin1(ba.toBase64().data());
|
||||
return "data:image/svg;base64," + QString::fromLatin1(image.toUtf8().toBase64().data());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
#define SHARE_CONNECTION_LOGIC_H
|
||||
|
||||
#include "PageLogicBase.h"
|
||||
#include "containers/containers_defs.h"
|
||||
|
||||
class UiLogic;
|
||||
|
||||
|
|
@ -48,8 +49,7 @@ public:
|
|||
void updateSharingPage(int serverIndex, DockerContainer container);
|
||||
QList<QString> genQrCodeImageSeries(const QByteArray &data);
|
||||
|
||||
QString imageToBase64(const QImage &image);
|
||||
|
||||
QString svgToBase64(const QString &image);
|
||||
|
||||
};
|
||||
#endif // SHARE_CONNECTION_LOGIC_H
|
||||
|
|
|
|||
|
|
@ -18,13 +18,13 @@ SitesLogic::SitesLogic(UiLogic *logic, QObject *parent):
|
|||
m_tableViewSitesModel{nullptr},
|
||||
m_lineEditSitesAddCustomText{}
|
||||
{
|
||||
sitesModels.insert(Settings::VpnOnlyForwardSites, new SitesModel(Settings::VpnOnlyForwardSites));
|
||||
sitesModels.insert(Settings::VpnAllExceptSites, new SitesModel(Settings::VpnAllExceptSites));
|
||||
sitesModels.insert(Settings::VpnOnlyForwardSites, new SitesModel(m_settings, Settings::VpnOnlyForwardSites));
|
||||
sitesModels.insert(Settings::VpnAllExceptSites, new SitesModel(m_settings, Settings::VpnAllExceptSites));
|
||||
}
|
||||
|
||||
void SitesLogic::onUpdatePage()
|
||||
{
|
||||
Settings::RouteMode m = m_settings.routeMode();
|
||||
Settings::RouteMode m = m_settings->routeMode();
|
||||
if (m == Settings::VpnAllSites) return;
|
||||
|
||||
if (m == Settings::VpnOnlyForwardSites) {
|
||||
|
|
@ -40,10 +40,10 @@ void SitesLogic::onUpdatePage()
|
|||
|
||||
void SitesLogic::onPushButtonAddCustomSitesClicked()
|
||||
{
|
||||
if (uiLogic()->vpnLogic()->radioButtonVpnModeAllSitesChecked()) {
|
||||
if (uiLogic()->pageLogic<VpnLogic>()->radioButtonVpnModeAllSitesChecked()) {
|
||||
return;
|
||||
}
|
||||
Settings::RouteMode mode = m_settings.routeMode();
|
||||
Settings::RouteMode mode = m_settings->routeMode();
|
||||
|
||||
QString newSite = lineEditSitesAddCustomText();
|
||||
|
||||
|
|
@ -60,7 +60,7 @@ void SitesLogic::onPushButtonAddCustomSitesClicked()
|
|||
}
|
||||
|
||||
const auto &cbProcess = [this, mode](const QString &newSite, const QString &ip) {
|
||||
m_settings.addVpnSite(mode, newSite, ip);
|
||||
m_settings->addVpnSite(mode, newSite, ip);
|
||||
|
||||
if (!ip.isEmpty()) {
|
||||
uiLogic()->m_vpnConnection->addRoutes(QStringList() << ip);
|
||||
|
|
@ -100,7 +100,7 @@ void SitesLogic::onPushButtonAddCustomSitesClicked()
|
|||
|
||||
void SitesLogic::onPushButtonSitesDeleteClicked(QStringList items)
|
||||
{
|
||||
Settings::RouteMode mode = m_settings.routeMode();
|
||||
Settings::RouteMode mode = m_settings->routeMode();
|
||||
|
||||
auto siteModel = qobject_cast<SitesModel*> (tableViewSitesModel());
|
||||
if (!siteModel || items.isEmpty()) {
|
||||
|
|
@ -121,7 +121,7 @@ void SitesLogic::onPushButtonSitesDeleteClicked(QStringList items)
|
|||
}
|
||||
}
|
||||
|
||||
m_settings.removeVpnSites(mode, sites);
|
||||
m_settings->removeVpnSites(mode, sites);
|
||||
|
||||
if (uiLogic()->m_vpnConnection->connectionState() == VpnProtocol::Connected) {
|
||||
uiLogic()->m_vpnConnection->deleteRoutes(ips);
|
||||
|
|
@ -139,7 +139,7 @@ void SitesLogic::onPushButtonSitesImportClicked(const QString& fileName)
|
|||
return;
|
||||
}
|
||||
|
||||
Settings::RouteMode mode = m_settings.routeMode();
|
||||
Settings::RouteMode mode = m_settings->routeMode();
|
||||
|
||||
QStringList ips;
|
||||
QMap<QString, QString> sites;
|
||||
|
|
@ -187,8 +187,8 @@ void SitesLogic::onPushButtonSitesImportClicked(const QString& fileName)
|
|||
|
||||
}
|
||||
|
||||
m_settings.addVpnIps(mode, ips);
|
||||
m_settings.addVpnSites(mode, sites);
|
||||
m_settings->addVpnIps(mode, ips);
|
||||
m_settings->addVpnSites(mode, sites);
|
||||
|
||||
uiLogic()->m_vpnConnection->addRoutes(QStringList() << ips);
|
||||
uiLogic()->m_vpnConnection->flushDns();
|
||||
|
|
@ -198,9 +198,9 @@ void SitesLogic::onPushButtonSitesImportClicked(const QString& fileName)
|
|||
|
||||
void SitesLogic::onPushButtonSitesExportClicked()
|
||||
{
|
||||
Settings::RouteMode mode = m_settings.routeMode();
|
||||
Settings::RouteMode mode = m_settings->routeMode();
|
||||
|
||||
QVariantMap sites = m_settings.vpnSites(mode);
|
||||
QVariantMap sites = m_settings->vpnSites(mode);
|
||||
|
||||
QString data;
|
||||
for (auto s : sites.keys()) {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
#define SITES_LOGIC_H
|
||||
|
||||
#include "PageLogicBase.h"
|
||||
#include "settings.h"
|
||||
|
||||
class UiLogic;
|
||||
class SitesModel;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
#include "StartPageLogic.h"
|
||||
#include "ViewConfigLogic.h"
|
||||
|
||||
#include "core/errorstrings.h"
|
||||
#include "configurators/ssh_configurator.h"
|
||||
#include "configurators/vpn_configurator.h"
|
||||
#include "../uilogic.h"
|
||||
#include "utilities.h"
|
||||
|
||||
|
|
@ -8,6 +11,7 @@
|
|||
#include <QStandardPaths>
|
||||
|
||||
#ifdef Q_OS_ANDROID
|
||||
#include <QtAndroid>
|
||||
#include "platforms/android/android_controller.h"
|
||||
#endif
|
||||
|
||||
|
|
@ -16,18 +20,20 @@ StartPageLogic::StartPageLogic(UiLogic *logic, QObject *parent):
|
|||
m_pushButtonConnectEnabled{true},
|
||||
m_pushButtonConnectText{tr("Connect")},
|
||||
m_pushButtonConnectKeyChecked{false},
|
||||
m_lineEditStartExistingCodeText{},
|
||||
m_textEditSshKeyText{},
|
||||
m_lineEditIpText{},
|
||||
m_lineEditPasswordText{},
|
||||
m_lineEditLoginText{},
|
||||
m_labelWaitInfoVisible{true},
|
||||
m_labelWaitInfoText{},
|
||||
m_pushButtonBackFromStartVisible{true},
|
||||
m_pushButtonConnectVisible{true},
|
||||
m_ipAddressPortRegex{Utils::ipAddressPortRegExp()}
|
||||
{
|
||||
|
||||
#ifdef Q_OS_ANDROID
|
||||
// Set security screen for Android app
|
||||
QtAndroid::runOnAndroidThread([]() {
|
||||
QAndroidJniObject window = QtAndroid::androidActivity().callObjectMethod("getWindow", "()Landroid/view/Window;");
|
||||
if (window.isValid()){
|
||||
const int FLAG_SECURE = 8192;
|
||||
window.callMethod<void>("addFlags", "(I)V", FLAG_SECURE);
|
||||
}
|
||||
});
|
||||
#endif
|
||||
}
|
||||
|
||||
void StartPageLogic::onUpdatePage()
|
||||
|
|
@ -41,7 +47,6 @@ void StartPageLogic::onUpdatePage()
|
|||
|
||||
set_labelWaitInfoVisible(false);
|
||||
set_labelWaitInfoText("");
|
||||
set_pushButtonConnectVisible(true);
|
||||
|
||||
set_pushButtonConnectKeyChecked(false);
|
||||
|
||||
|
|
@ -50,8 +55,6 @@ void StartPageLogic::onUpdatePage()
|
|||
|
||||
void StartPageLogic::onPushButtonConnect()
|
||||
{
|
||||
// uiLogic()->goToPage(Page::NewServer);
|
||||
// return;
|
||||
if (pushButtonConnectKeyChecked()){
|
||||
if (lineEditIpText().isEmpty() ||
|
||||
lineEditLoginText().isEmpty() ||
|
||||
|
|
@ -68,7 +71,6 @@ void StartPageLogic::onPushButtonConnect()
|
|||
return;
|
||||
}
|
||||
}
|
||||
qDebug() << "UiLogic::onPushButtonConnect checking new server";
|
||||
|
||||
ServerCredentials serverCredentials;
|
||||
serverCredentials.hostName = lineEditIpText();
|
||||
|
|
@ -85,7 +87,7 @@ void StartPageLogic::onPushButtonConnect()
|
|||
}
|
||||
|
||||
if (key.contains("OPENSSH") && key.contains("BEGIN") && key.contains("PRIVATE KEY")) {
|
||||
key = SshConfigurator::convertOpenSShKey(key);
|
||||
key = m_configurator->sshConfigurator->convertOpenSShKey(key);
|
||||
}
|
||||
|
||||
serverCredentials.password = key;
|
||||
|
|
@ -99,7 +101,7 @@ void StartPageLogic::onPushButtonConnect()
|
|||
|
||||
ErrorCode e = ErrorCode::NoError;
|
||||
#ifdef Q_DEBUG
|
||||
//QString output = ServerController::checkSshConnection(serverCredentials, &e);
|
||||
//QString output = m_serverController->checkSshConnection(serverCredentials, &e);
|
||||
#else
|
||||
QString output;
|
||||
#endif
|
||||
|
|
@ -153,19 +155,10 @@ bool StartPageLogic::importConnection(const QJsonObject &profile)
|
|||
credentials.userName = profile.value(config_key::userName).toString();
|
||||
credentials.password = profile.value(config_key::password).toString();
|
||||
|
||||
// qDebug() << QString("Added server %3@%1:%2").
|
||||
// arg(credentials.hostName).
|
||||
// arg(credentials.port).
|
||||
// arg(credentials.userName);
|
||||
|
||||
//qDebug() << QString("Password") << credentials.password;
|
||||
|
||||
if (credentials.isValid() || profile.contains(config_key::containers)) {
|
||||
m_settings.addServer(profile);
|
||||
m_settings.setDefaultServer(m_settings.serversCount() - 1);
|
||||
|
||||
emit uiLogic()->goToPage(Page::Vpn);
|
||||
emit uiLogic()->setStartPage(Page::Vpn);
|
||||
// check config
|
||||
uiLogic()->pageLogic<ViewConfigLogic>()->set_configJson(profile);
|
||||
emit uiLogic()->goToPage(Page::ViewConfig);
|
||||
}
|
||||
else {
|
||||
qDebug() << "Failed to import profile";
|
||||
|
|
@ -174,8 +167,8 @@ bool StartPageLogic::importConnection(const QJsonObject &profile)
|
|||
}
|
||||
|
||||
if (!profile.contains(config_key::containers)) {
|
||||
uiLogic()->selectedServerIndex = m_settings.defaultServerIndex();
|
||||
uiLogic()->selectedDockerContainer = m_settings.defaultContainer(uiLogic()->selectedServerIndex);
|
||||
uiLogic()->selectedServerIndex = m_settings->defaultServerIndex();
|
||||
uiLogic()->selectedDockerContainer = m_settings->defaultContainer(uiLogic()->selectedServerIndex);
|
||||
uiLogic()->onUpdateAllPages();
|
||||
|
||||
emit uiLogic()->goToPage(Page::ServerContainers);
|
||||
|
|
@ -209,7 +202,6 @@ bool StartPageLogic::importConnectionFromCode(QString code)
|
|||
|
||||
bool StartPageLogic::importConnectionFromQr(const QByteArray &data)
|
||||
{
|
||||
qDebug() << "StartPageLogic::importConnectionFromQr" << data;
|
||||
QJsonObject dataObj = QJsonDocument::fromJson(data).object();
|
||||
if (!dataObj.isEmpty()) {
|
||||
return importConnection(dataObj);
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include "PageLogicBase.h"
|
||||
|
||||
#include <QRegExp>
|
||||
#include <QRegularExpression>
|
||||
|
||||
class UiLogic;
|
||||
|
||||
|
|
@ -22,7 +22,6 @@ class StartPageLogic : public PageLogicBase
|
|||
AUTO_PROPERTY(bool, labelWaitInfoVisible)
|
||||
AUTO_PROPERTY(QString, labelWaitInfoText)
|
||||
AUTO_PROPERTY(bool, pushButtonBackFromStartVisible)
|
||||
AUTO_PROPERTY(bool, pushButtonConnectVisible)
|
||||
|
||||
READONLY_PROPERTY(QRegularExpression, ipAddressPortRegex)
|
||||
public:
|
||||
|
|
|
|||
67
client/ui/pages_logic/ViewConfigLogic.cpp
Normal file
67
client/ui/pages_logic/ViewConfigLogic.cpp
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
#include "ViewConfigLogic.h"
|
||||
#include "core/errorstrings.h"
|
||||
#include "../uilogic.h"
|
||||
|
||||
|
||||
ViewConfigLogic::ViewConfigLogic(UiLogic *logic, QObject *parent):
|
||||
PageLogicBase(logic, parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ViewConfigLogic::onUpdatePage()
|
||||
{
|
||||
set_configText(QJsonDocument(configJson()).toJson());
|
||||
|
||||
m_openVpnLastConfigs = m_openVpnMalStrings =
|
||||
"<style> \
|
||||
div { line-height: 0.5; } \
|
||||
</style><div>";
|
||||
|
||||
m_warningStringNumber = 3;
|
||||
m_warningActive = false;
|
||||
|
||||
const QJsonArray &containers = configJson()[config_key::containers].toArray();
|
||||
int i = 0;
|
||||
for (const QJsonValue &v: containers) {
|
||||
QString cfg_json = v.toObject()[ProtocolProps::protoToString(Proto::OpenVpn)]
|
||||
.toObject()[config_key::last_config].toString();
|
||||
|
||||
QString openvpn_cfg = QJsonDocument::fromJson(cfg_json.toUtf8()).object()[config_key::config]
|
||||
.toString();
|
||||
|
||||
openvpn_cfg.replace("\r", "");
|
||||
|
||||
QStringList lines = openvpn_cfg.split("\n");
|
||||
for (const QString &l: lines) {
|
||||
i++;
|
||||
QRegularExpressionMatch match = m_re.match(l);
|
||||
if (dangerousTags.contains(match.captured(0))) {
|
||||
QString t = QString("<p><font color=\"red\">%1</font>").arg(l);
|
||||
m_openVpnLastConfigs.append(t + "\n");
|
||||
m_openVpnMalStrings.append(t);
|
||||
if (m_warningStringNumber == 3) m_warningStringNumber = i - 3;
|
||||
m_warningActive = true;
|
||||
qDebug() << "ViewConfigLogic : malicious scripts warning:" << l;
|
||||
}
|
||||
else {
|
||||
m_openVpnLastConfigs.append("<p>" + l + " \n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
emit openVpnLastConfigsChanged(m_openVpnLastConfigs);
|
||||
emit openVpnMalStringsChanged(m_openVpnMalStrings);
|
||||
emit warningStringNumberChanged(m_warningStringNumber);
|
||||
emit warningActiveChanged(m_warningActive);
|
||||
}
|
||||
|
||||
void ViewConfigLogic::importConfig()
|
||||
{
|
||||
m_settings->addServer(configJson());
|
||||
m_settings->setDefaultServer(m_settings->serversCount() - 1);
|
||||
|
||||
emit uiLogic()->goToPage(Page::Vpn);
|
||||
emit uiLogic()->setStartPage(Page::Vpn);
|
||||
}
|
||||
|
||||
47
client/ui/pages_logic/ViewConfigLogic.h
Normal file
47
client/ui/pages_logic/ViewConfigLogic.h
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
#ifndef VIEW_CONFIG_LOGIC_H
|
||||
#define VIEW_CONFIG_LOGIC_H
|
||||
|
||||
#include "PageLogicBase.h"
|
||||
|
||||
#include <QJsonObject>
|
||||
|
||||
class UiLogic;
|
||||
|
||||
class ViewConfigLogic : public PageLogicBase
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
AUTO_PROPERTY(QString, configText)
|
||||
AUTO_PROPERTY(QString, openVpnLastConfigs)
|
||||
AUTO_PROPERTY(QString, openVpnMalStrings)
|
||||
AUTO_PROPERTY(QJsonObject, configJson)
|
||||
AUTO_PROPERTY(int, warningStringNumber)
|
||||
AUTO_PROPERTY(bool, warningActive)
|
||||
|
||||
public:
|
||||
Q_INVOKABLE void onUpdatePage() override;
|
||||
Q_INVOKABLE void importConfig();
|
||||
|
||||
|
||||
public:
|
||||
explicit ViewConfigLogic(UiLogic *uiLogic, QObject *parent = nullptr);
|
||||
~ViewConfigLogic() = default;
|
||||
|
||||
private:
|
||||
QRegularExpression m_re {"(\\w+-\\w+|\\w+)"};
|
||||
|
||||
// https://github.com/OpenVPN/openvpn/blob/master/doc/man-sections/script-options.rst
|
||||
QStringList dangerousTags {
|
||||
"up",
|
||||
"tls-verify",
|
||||
"ipchange",
|
||||
"client-connect",
|
||||
"route-up",
|
||||
"route-pre-down",
|
||||
"client-disconnect",
|
||||
"down",
|
||||
"learn-address",
|
||||
"auth-user-pass-verify"
|
||||
};
|
||||
};
|
||||
#endif // VIEW_CONFIG_LOGIC_H
|
||||
|
|
@ -33,7 +33,7 @@ VpnLogic::VpnLogic(UiLogic *logic, QObject *parent):
|
|||
connect(this, &VpnLogic::connectToVpn, uiLogic()->m_vpnConnection, &VpnConnection::connectToVpn, Qt::QueuedConnection);
|
||||
connect(this, &VpnLogic::disconnectFromVpn, uiLogic()->m_vpnConnection, &VpnConnection::disconnectFromVpn, Qt::QueuedConnection);
|
||||
|
||||
if (m_settings.isAutoConnect() && m_settings.defaultServerIndex() >= 0) {
|
||||
if (m_settings->isAutoConnect() && m_settings->defaultServerIndex() >= 0) {
|
||||
QTimer::singleShot(1000, this, [this](){
|
||||
set_pushButtonConnectEnabled(false);
|
||||
onConnect();
|
||||
|
|
@ -47,20 +47,20 @@ VpnLogic::VpnLogic(UiLogic *logic, QObject *parent):
|
|||
|
||||
void VpnLogic::onUpdatePage()
|
||||
{
|
||||
Settings::RouteMode mode = m_settings.routeMode();
|
||||
DockerContainer selectedContainer = m_settings.defaultContainer(m_settings.defaultServerIndex());
|
||||
Settings::RouteMode mode = m_settings->routeMode();
|
||||
DockerContainer selectedContainer = m_settings->defaultContainer(m_settings->defaultServerIndex());
|
||||
|
||||
set_isCustomRoutesSupported (selectedContainer == DockerContainer::OpenVpn ||
|
||||
selectedContainer == DockerContainer::ShadowSocks||
|
||||
selectedContainer == DockerContainer::Cloak);
|
||||
|
||||
set_isContainerHaveAuthData(m_settings.haveAuthData(m_settings.defaultServerIndex()));
|
||||
set_isContainerHaveAuthData(m_settings->haveAuthData(m_settings->defaultServerIndex()));
|
||||
|
||||
set_radioButtonVpnModeAllSitesChecked(mode == Settings::VpnAllSites || !isCustomRoutesSupported());
|
||||
set_radioButtonVpnModeForwardSitesChecked(mode == Settings::VpnOnlyForwardSites && isCustomRoutesSupported());
|
||||
set_radioButtonVpnModeExceptSitesChecked(mode == Settings::VpnAllExceptSites && isCustomRoutesSupported());
|
||||
|
||||
const QJsonObject &server = uiLogic()->m_settings.defaultServer();
|
||||
const QJsonObject &server = uiLogic()->m_settings->defaultServer();
|
||||
QString serverString = QString("%2 (%3)")
|
||||
.arg(server.value(config_key::description).toString())
|
||||
.arg(server.value(config_key::hostName).toString());
|
||||
|
|
@ -69,7 +69,7 @@ void VpnLogic::onUpdatePage()
|
|||
QString selectedContainerName = ContainerProps::containerHumanNames().value(selectedContainer);
|
||||
set_labelCurrentService(selectedContainerName);
|
||||
|
||||
auto dns = VpnConfigurator::getDnsForConfig(m_settings.defaultServerIndex());
|
||||
auto dns = m_configurator->getDnsForConfig(m_settings->defaultServerIndex());
|
||||
set_amneziaDnsEnabled(dns.first == protocols::dns::amneziaDnsIp);
|
||||
if (dns.first == protocols::dns::amneziaDnsIp) {
|
||||
set_labelCurrentDns("On your server");
|
||||
|
|
@ -93,19 +93,19 @@ void VpnLogic::onUpdatePage()
|
|||
|
||||
void VpnLogic::onRadioButtonVpnModeAllSitesClicked()
|
||||
{
|
||||
m_settings.setRouteMode(Settings::VpnAllSites);
|
||||
m_settings->setRouteMode(Settings::VpnAllSites);
|
||||
onUpdatePage();
|
||||
}
|
||||
|
||||
void VpnLogic::onRadioButtonVpnModeForwardSitesClicked()
|
||||
{
|
||||
m_settings.setRouteMode(Settings::VpnOnlyForwardSites);
|
||||
m_settings->setRouteMode(Settings::VpnOnlyForwardSites);
|
||||
onUpdatePage();
|
||||
}
|
||||
|
||||
void VpnLogic::onRadioButtonVpnModeExceptSitesClicked()
|
||||
{
|
||||
m_settings.setRouteMode(Settings::VpnAllExceptSites);
|
||||
m_settings->setRouteMode(Settings::VpnAllExceptSites);
|
||||
onUpdatePage();
|
||||
}
|
||||
|
||||
|
|
@ -203,11 +203,11 @@ void VpnLogic::onPushButtonConnectClicked()
|
|||
|
||||
void VpnLogic::onConnect()
|
||||
{
|
||||
int serverIndex = m_settings.defaultServerIndex();
|
||||
ServerCredentials credentials = m_settings.serverCredentials(serverIndex);
|
||||
DockerContainer container = m_settings.defaultContainer(serverIndex);
|
||||
int serverIndex = m_settings->defaultServerIndex();
|
||||
ServerCredentials credentials = m_settings->serverCredentials(serverIndex);
|
||||
DockerContainer container = m_settings->defaultContainer(serverIndex);
|
||||
|
||||
if (m_settings.containers(serverIndex).isEmpty()) {
|
||||
if (m_settings->containers(serverIndex).isEmpty()) {
|
||||
set_labelErrorText(tr("VPN Protocols is not installed.\n Please install VPN container at first"));
|
||||
set_pushButtonConnectChecked(false);
|
||||
return;
|
||||
|
|
@ -220,7 +220,7 @@ void VpnLogic::onConnect()
|
|||
}
|
||||
|
||||
|
||||
const QJsonObject &containerConfig = m_settings.containerConfig(serverIndex, container);
|
||||
const QJsonObject &containerConfig = m_settings->containerConfig(serverIndex, container);
|
||||
onConnectWorker(serverIndex, credentials, container, containerConfig);
|
||||
}
|
||||
|
||||
|
|
@ -233,14 +233,6 @@ void VpnLogic::onConnectWorker(int serverIndex, const ServerCredentials &credent
|
|||
qApp->processEvents();
|
||||
|
||||
emit connectToVpn(serverIndex, credentials, container, containerConfig);
|
||||
|
||||
// if (errorCode) {
|
||||
// //ui->pushButton_connect->setChecked(false);
|
||||
// uiLogic()->setDialogConnectErrorText(errorString(errorCode));
|
||||
// emit uiLogic()->showConnectErrorDialog();
|
||||
// return;
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
void VpnLogic::onDisconnect()
|
||||
|
|
|
|||
|
|
@ -55,9 +55,9 @@ void WizardLogic::onPushButtonVpnModeFinishClicked()
|
|||
auto containers = getInstallConfigsFromWizardPage();
|
||||
uiLogic()->installServer(containers);
|
||||
if (checkBoxVpnModeChecked()) {
|
||||
m_settings.setRouteMode(Settings::VpnOnlyForwardSites);
|
||||
m_settings->setRouteMode(Settings::VpnOnlyForwardSites);
|
||||
} else {
|
||||
m_settings.setRouteMode(Settings::VpnAllSites);
|
||||
m_settings->setRouteMode(Settings::VpnAllSites);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
#define WIZARD_LOGIC_H
|
||||
|
||||
#include "PageLogicBase.h"
|
||||
#include "containers/containers_defs.h"
|
||||
|
||||
class UiLogic;
|
||||
|
||||
|
|
|
|||
|
|
@ -52,10 +52,10 @@ QJsonObject CloakLogic::getProtocolConfigFromPage(QJsonObject oldConfig)
|
|||
|
||||
void CloakLogic::onPushButtonSaveClicked()
|
||||
{
|
||||
QJsonObject protocolConfig = m_settings.protocolConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer, Proto::Cloak);
|
||||
QJsonObject protocolConfig = m_settings->protocolConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer, Proto::Cloak);
|
||||
protocolConfig = getProtocolConfigFromPage(protocolConfig);
|
||||
|
||||
QJsonObject containerConfig = m_settings.containerConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer);
|
||||
QJsonObject containerConfig = m_settings->containerConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer);
|
||||
QJsonObject newContainerConfig = containerConfig;
|
||||
newContainerConfig.insert(ProtocolProps::protoToString(Proto::Cloak), protocolConfig);
|
||||
|
||||
|
|
@ -89,14 +89,14 @@ void CloakLogic::onPushButtonSaveClicked()
|
|||
};
|
||||
|
||||
ErrorCode e = uiLogic()->doInstallAction([this, containerConfig, &newContainerConfig](){
|
||||
return ServerController::updateContainer(m_settings.serverCredentials(uiLogic()->selectedServerIndex), uiLogic()->selectedDockerContainer, containerConfig, newContainerConfig);
|
||||
return m_serverController->updateContainer(m_settings->serverCredentials(uiLogic()->selectedServerIndex), uiLogic()->selectedDockerContainer, containerConfig, newContainerConfig);
|
||||
},
|
||||
page_func, progressBar_reset,
|
||||
pushButton_save_func, label_info_func);
|
||||
|
||||
if (!e) {
|
||||
m_settings.setContainerConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer, newContainerConfig);
|
||||
m_settings.clearLastConnectionConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer);
|
||||
m_settings->setContainerConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer, newContainerConfig);
|
||||
m_settings->clearLastConnectionConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer);
|
||||
}
|
||||
|
||||
qDebug() << "Protocol saved with code:" << e << "for" << uiLogic()->selectedServerIndex << uiLogic()->selectedDockerContainer;
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ public:
|
|||
QJsonObject getProtocolConfigFromPage(QJsonObject oldConfig) override;
|
||||
|
||||
private:
|
||||
Settings m_settings;
|
||||
UiLogic *m_uiLogic;
|
||||
|
||||
};
|
||||
|
|
|
|||
|
|
@ -81,10 +81,10 @@ void OpenVpnLogic::updateProtocolPage(const QJsonObject &openvpnConfig, DockerCo
|
|||
|
||||
void OpenVpnLogic::onPushButtonProtoOpenVpnSaveClicked()
|
||||
{
|
||||
QJsonObject protocolConfig = m_settings.protocolConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer, Proto::OpenVpn);
|
||||
QJsonObject protocolConfig = m_settings->protocolConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer, Proto::OpenVpn);
|
||||
protocolConfig = getProtocolConfigFromPage(protocolConfig);
|
||||
|
||||
QJsonObject containerConfig = m_settings.containerConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer);
|
||||
QJsonObject containerConfig = m_settings->containerConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer);
|
||||
QJsonObject newContainerConfig = containerConfig;
|
||||
newContainerConfig.insert(ProtocolProps::protoToString(Proto::OpenVpn), protocolConfig);
|
||||
|
||||
|
|
@ -118,14 +118,14 @@ void OpenVpnLogic::onPushButtonProtoOpenVpnSaveClicked()
|
|||
};
|
||||
|
||||
ErrorCode e = uiLogic()->doInstallAction([this, containerConfig, &newContainerConfig](){
|
||||
return ServerController::updateContainer(m_settings.serverCredentials(uiLogic()->selectedServerIndex), uiLogic()->selectedDockerContainer, containerConfig, newContainerConfig);
|
||||
return m_serverController->updateContainer(m_settings->serverCredentials(uiLogic()->selectedServerIndex), uiLogic()->selectedDockerContainer, containerConfig, newContainerConfig);
|
||||
},
|
||||
page_proto_openvpn, progressBar_proto_openvpn_reset,
|
||||
pushButton_proto_openvpn_save, label_proto_openvpn_info);
|
||||
|
||||
if (!e) {
|
||||
m_settings.setContainerConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer, newContainerConfig);
|
||||
m_settings.clearLastConnectionConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer);
|
||||
m_settings->setContainerConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer, newContainerConfig);
|
||||
m_settings->clearLastConnectionConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer);
|
||||
}
|
||||
qDebug() << "Protocol saved with code:" << e << "for" << uiLogic()->selectedServerIndex << uiLogic()->selectedDockerContainer;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,7 +44,6 @@ public:
|
|||
QJsonObject getProtocolConfigFromPage(QJsonObject oldConfig) override;
|
||||
|
||||
private:
|
||||
Settings m_settings;
|
||||
UiLogic *m_uiLogic;
|
||||
|
||||
};
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@
|
|||
#include <QStandardPaths>
|
||||
|
||||
#include "OtherProtocolsLogic.h"
|
||||
#include "core/servercontroller.h"
|
||||
#include <functional>
|
||||
#include "../../uilogic.h"
|
||||
#include "utilities.h"
|
||||
|
|
@ -82,7 +81,7 @@ void OtherProtocolsLogic::onPushButtonSftpMountDriveClicked()
|
|||
{
|
||||
QString mountPath;
|
||||
QString cmd;
|
||||
QString host = m_settings.serverCredentials(uiLogic()->selectedServerIndex).hostName;
|
||||
QString host = m_settings->serverCredentials(uiLogic()->selectedServerIndex).hostName;
|
||||
|
||||
|
||||
#ifdef Q_OS_WINDOWS
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ public:
|
|||
//QJsonObject getProtocolConfigFromPage(QJsonObject oldConfig) override;
|
||||
|
||||
private:
|
||||
Settings m_settings;
|
||||
UiLogic *m_uiLogic;
|
||||
|
||||
#ifdef AMNEZIA_DESKTOP
|
||||
|
|
|
|||
|
|
@ -46,10 +46,9 @@ QJsonObject ShadowSocksLogic::getProtocolConfigFromPage(QJsonObject oldConfig)
|
|||
|
||||
void ShadowSocksLogic::onPushButtonSaveClicked()
|
||||
{
|
||||
QJsonObject protocolConfig = m_settings.protocolConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer, Proto::ShadowSocks);
|
||||
//protocolConfig = getShadowSocksConfigFromPage(protocolConfig);
|
||||
QJsonObject protocolConfig = m_settings->protocolConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer, Proto::ShadowSocks);
|
||||
|
||||
QJsonObject containerConfig = m_settings.containerConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer);
|
||||
QJsonObject containerConfig = m_settings->containerConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer);
|
||||
QJsonObject newContainerConfig = containerConfig;
|
||||
newContainerConfig.insert(ProtocolProps::protoToString(Proto::ShadowSocks), protocolConfig);
|
||||
UiLogic::PageFunc page_proto_shadowsocks;
|
||||
|
|
@ -82,14 +81,14 @@ void ShadowSocksLogic::onPushButtonSaveClicked()
|
|||
};
|
||||
|
||||
ErrorCode e = uiLogic()->doInstallAction([this, containerConfig, &newContainerConfig](){
|
||||
return ServerController::updateContainer(m_settings.serverCredentials(uiLogic()->selectedServerIndex), uiLogic()->selectedDockerContainer, containerConfig, newContainerConfig);
|
||||
return m_serverController->updateContainer(m_settings->serverCredentials(uiLogic()->selectedServerIndex), uiLogic()->selectedDockerContainer, containerConfig, newContainerConfig);
|
||||
},
|
||||
page_proto_shadowsocks, progressBar_reset,
|
||||
pushButton_proto_shadowsocks_save, label_proto_shadowsocks_info);
|
||||
|
||||
if (!e) {
|
||||
m_settings.setContainerConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer, newContainerConfig);
|
||||
m_settings.clearLastConnectionConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer);
|
||||
m_settings->setContainerConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer, newContainerConfig);
|
||||
m_settings->clearLastConnectionConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer);
|
||||
}
|
||||
qDebug() << "Protocol saved with code:" << e << "for" << uiLogic()->selectedServerIndex << uiLogic()->selectedDockerContainer;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ public:
|
|||
QJsonObject getProtocolConfigFromPage(QJsonObject oldConfig) override;
|
||||
|
||||
private:
|
||||
Settings m_settings;
|
||||
UiLogic *m_uiLogic;
|
||||
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue