Merge branch 'dev' of github.com:amnezia-vpn/amnezia-client into feature/qt6-client-management-panel
This commit is contained in:
commit
ada8912a1f
208 changed files with 1860 additions and 1503607 deletions
|
|
@ -44,11 +44,11 @@ void AdvancedServerSettingsLogic::onPushButtonClearServerClicked()
|
|||
uiLogic()->pageLogic<VpnLogic>()->onDisconnect();
|
||||
}
|
||||
|
||||
ErrorCode e = m_serverController->removeAllContainers(m_settings->serverCredentials(uiLogic()->m_selectedServerIndex));
|
||||
m_serverController->disconnectFromHost(m_settings->serverCredentials(uiLogic()->m_selectedServerIndex));
|
||||
if (e) {
|
||||
ServerController serverController(m_settings);
|
||||
ErrorCode errorCode = serverController.removeAllContainers(m_settings->serverCredentials(uiLogic()->m_selectedServerIndex));
|
||||
if (errorCode) {
|
||||
emit uiLogic()->showWarningMessage(tr("Error occurred while cleaning the server.") + "\n" +
|
||||
tr("Error message: ") + errorString(e) + "\n" +
|
||||
tr("Error message: ") + errorString(errorCode) + "\n" +
|
||||
tr("See logs for details."));
|
||||
} else {
|
||||
set_labelWaitInfoVisible(true);
|
||||
|
|
@ -69,7 +69,7 @@ void AdvancedServerSettingsLogic::onPushButtonScanServerClicked()
|
|||
|
||||
bool isServerCreated;
|
||||
auto containersCount = m_settings->containers(uiLogic()->m_selectedServerIndex).size();
|
||||
ErrorCode errorCode = uiLogic()->addAlreadyInstalledContainersGui(false, isServerCreated);
|
||||
ErrorCode errorCode = uiLogic()->addAlreadyInstalledContainersGui(isServerCreated);
|
||||
if (errorCode != ErrorCode::NoError) {
|
||||
emit uiLogic()->showWarningMessage(tr("Error occurred while scanning the server.") + "\n" +
|
||||
tr("Error message: ") + errorString(errorCode) + "\n" +
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
#include <QDesktopServices>
|
||||
#include <QFileDialog>
|
||||
#include <QStandardPaths>
|
||||
#include <utilities.h>
|
||||
|
||||
using namespace amnezia;
|
||||
using namespace PageEnumNS;
|
||||
|
|
@ -82,8 +83,8 @@ void AppSettingsLogic::onPushButtonBackupAppConfigClicked()
|
|||
|
||||
void AppSettingsLogic::onPushButtonRestoreAppConfigClicked()
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(Q_NULLPTR, tr("Open backup"),
|
||||
QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), "*.backup");
|
||||
QString fileName = UiLogic::getOpenFileName(Q_NULLPTR, tr("Open backup"),
|
||||
QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), "*.backup");
|
||||
|
||||
if (fileName.isEmpty()) return;
|
||||
|
||||
|
|
@ -98,6 +99,5 @@ void AppSettingsLogic::onPushButtonRestoreAppConfigClicked()
|
|||
} else {
|
||||
emit uiLogic()->showWarningMessage(tr("Can't import config, file is corrupted."));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -54,16 +54,17 @@ void ClientInfoLogic::onUpdatePage()
|
|||
|
||||
if (certData.isEmpty() && !certId.isEmpty()) {
|
||||
QString stdOut;
|
||||
auto cbReadStdOut = [&](const QString &data, QSharedPointer<QSsh::SshRemoteProcess> proc) {
|
||||
auto cbReadStdOut = [&](const QString &data, libssh::Client &) {
|
||||
stdOut += data + "\n";
|
||||
return ErrorCode::NoError;
|
||||
};
|
||||
|
||||
const QString getOpenVpnCertData = QString("sudo docker exec -i $CONTAINER_NAME bash -c 'cat /opt/amnezia/openvpn/pki/issued/%1.crt'")
|
||||
.arg(certId);
|
||||
const QString script = m_serverController->replaceVars(getOpenVpnCertData, m_serverController->genVarsForScript(credentials, container));
|
||||
ErrorCode error = m_serverController->runScript(credentials, script, cbReadStdOut);
|
||||
ServerController serverController(m_settings);
|
||||
const QString script = serverController.replaceVars(getOpenVpnCertData, serverController.genVarsForScript(credentials, container));
|
||||
ErrorCode error = serverController.runScript(credentials, script, cbReadStdOut);
|
||||
certData = stdOut;
|
||||
m_serverController->disconnectFromHost(credentials);
|
||||
if (isErrorOccured(error)) {
|
||||
set_busyIndicatorIsRunning(false);
|
||||
emit uiLogic()->closePage();
|
||||
|
|
@ -101,7 +102,6 @@ void ClientInfoLogic::onLineEditNameAliasEditingFinished()
|
|||
isErrorOccured(error);
|
||||
}
|
||||
|
||||
m_serverController->disconnectFromHost(credentials);
|
||||
set_busyIndicatorIsRunning(false);
|
||||
}
|
||||
|
||||
|
|
@ -120,9 +120,10 @@ void ClientInfoLogic::onRevokeOpenVpnCertificateClicked()
|
|||
"easyrsa revoke %1 ;\\"
|
||||
"easyrsa gen-crl ;\\"
|
||||
"cp pki/crl.pem .'").arg(certId);
|
||||
const QString script = m_serverController->replaceVars(getOpenVpnCertData,
|
||||
m_serverController->genVarsForScript(credentials, container));
|
||||
auto error = m_serverController->runScript(credentials, script);
|
||||
ServerController serverController(m_settings);
|
||||
const QString script = serverController.replaceVars(getOpenVpnCertData,
|
||||
serverController.genVarsForScript(credentials, container));
|
||||
auto error = serverController.runScript(credentials, script);
|
||||
if (isErrorOccured(error)) {
|
||||
set_busyIndicatorIsRunning(false);
|
||||
emit uiLogic()->goToPage(Page::ServerSettings);
|
||||
|
|
@ -138,12 +139,12 @@ void ClientInfoLogic::onRevokeOpenVpnCertificateClicked()
|
|||
}
|
||||
|
||||
const QJsonObject &containerConfig = m_settings->containerConfig(uiLogic()->m_selectedServerIndex, container);
|
||||
error = m_serverController->startupContainerWorker(credentials, container, containerConfig);
|
||||
error = serverController.startupContainerWorker(credentials, container, containerConfig);
|
||||
if (isErrorOccured(error)) {
|
||||
set_busyIndicatorIsRunning(false);
|
||||
return;
|
||||
}
|
||||
m_serverController->disconnectFromHost(credentials);
|
||||
|
||||
set_busyIndicatorIsRunning(false);
|
||||
}
|
||||
|
||||
|
|
@ -153,8 +154,11 @@ void ClientInfoLogic::onRevokeWireGuardKeyClicked()
|
|||
ErrorCode error;
|
||||
const DockerContainer container = m_settings->defaultContainer(uiLogic()->m_selectedServerIndex);
|
||||
const ServerCredentials credentials = m_settings->serverCredentials(uiLogic()->m_selectedServerIndex);
|
||||
|
||||
ServerController serverController(m_settings);
|
||||
|
||||
const QString wireGuardConfigFile = "opt/amnezia/wireguard/wg0.conf";
|
||||
const QString wireguardConfigString = m_serverController->getTextFileFromContainer(container, credentials, wireGuardConfigFile, &error);
|
||||
const QString wireguardConfigString = serverController.getTextFileFromContainer(container, credentials, wireGuardConfigFile, &error);
|
||||
if (isErrorOccured(error)) {
|
||||
set_busyIndicatorIsRunning(false);
|
||||
return;
|
||||
|
|
@ -172,9 +176,9 @@ void ClientInfoLogic::onRevokeWireGuardKeyClicked()
|
|||
}
|
||||
QString newWireGuardConfig = configSections.join("[");
|
||||
newWireGuardConfig.insert(0, "[");
|
||||
error = m_serverController->uploadTextFileToContainer(container, credentials, newWireGuardConfig,
|
||||
protocols::wireguard::serverConfigPath,
|
||||
QSsh::SftpOverwriteMode::SftpOverwriteExisting);
|
||||
error = serverController.uploadTextFileToContainer(container, credentials, newWireGuardConfig,
|
||||
protocols::wireguard::serverConfigPath,
|
||||
libssh::SftpOverwriteMode::SftpOverwriteExisting);
|
||||
if (isErrorOccured(error)) {
|
||||
set_busyIndicatorIsRunning(false);
|
||||
return;
|
||||
|
|
@ -188,14 +192,14 @@ void ClientInfoLogic::onRevokeWireGuardKeyClicked()
|
|||
return;
|
||||
}
|
||||
|
||||
error = m_serverController->runScript(credentials,
|
||||
m_serverController->replaceVars("sudo docker exec -i $CONTAINER_NAME bash -c 'wg syncconf wg0 <(wg-quick strip /opt/amnezia/wireguard/wg0.conf)'",
|
||||
m_serverController->genVarsForScript(credentials, container)));
|
||||
const QString script = "sudo docker exec -i $CONTAINER_NAME bash -c 'wg syncconf wg0 <(wg-quick strip /opt/amnezia/wireguard/wg0.conf)'";
|
||||
error = serverController.runScript(credentials,
|
||||
serverController.replaceVars(script, serverController.genVarsForScript(credentials, container)));
|
||||
if (isErrorOccured(error)) {
|
||||
set_busyIndicatorIsRunning(false);
|
||||
return;
|
||||
}
|
||||
m_serverController->disconnectFromHost(credentials);
|
||||
|
||||
set_busyIndicatorIsRunning(false);
|
||||
}
|
||||
|
||||
|
|
@ -203,6 +207,7 @@ ErrorCode ClientInfoLogic::setClientsList(const ServerCredentials &credentials,
|
|||
{
|
||||
const QString mainProtocolString = ProtocolProps::protoToString(mainProtocol);
|
||||
const QString clientsTableFile = QString("opt/amnezia/%1/clientsTable").arg(mainProtocolString);
|
||||
ErrorCode error = m_serverController->uploadTextFileToContainer(container, credentials, QJsonDocument(clietns).toJson(), clientsTableFile);
|
||||
ServerController serverController(m_settings);
|
||||
ErrorCode error = serverController.uploadTextFileToContainer(container, credentials, QJsonDocument(clietns).toJson(), clientsTableFile);
|
||||
return error;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@ void ClientManagementLogic::onUpdatePage()
|
|||
const ServerCredentials credentials = m_settings->serverCredentials(uiLogic()->m_selectedServerIndex);
|
||||
|
||||
ErrorCode error = getClientsList(credentials, selectedContainer, m_currentMainProtocol, clients);
|
||||
m_serverController->disconnectFromHost(credentials);
|
||||
if (error != ErrorCode::NoError) {
|
||||
QMessageBox::warning(nullptr, APPLICATION_NAME,
|
||||
tr("An error occurred while getting the list of clients.") + "\n" + errorString(error));
|
||||
|
|
@ -60,14 +59,17 @@ ErrorCode ClientManagementLogic::getClientsList(const ServerCredentials &credent
|
|||
{
|
||||
ErrorCode error = ErrorCode::NoError;
|
||||
QString stdOut;
|
||||
auto cbReadStdOut = [&](const QString &data, QSharedPointer<QSsh::SshRemoteProcess> proc) {
|
||||
auto cbReadStdOut = [&](const QString &data, libssh::Client &) {
|
||||
stdOut += data + "\n";
|
||||
return ErrorCode::NoError;
|
||||
};
|
||||
|
||||
const QString mainProtocolString = ProtocolProps::protoToString(mainProtocol);
|
||||
|
||||
ServerController serverController(m_settings);
|
||||
|
||||
const QString clientsTableFile = QString("/opt/amnezia/%1/clientsTable").arg(mainProtocolString);
|
||||
const QByteArray clientsTableString = m_serverController->getTextFileFromContainer(container, credentials, clientsTableFile, &error);
|
||||
const QByteArray clientsTableString = serverController.getTextFileFromContainer(container, credentials, clientsTableFile, &error);
|
||||
if (error != ErrorCode::NoError) {
|
||||
return error;
|
||||
}
|
||||
|
|
@ -76,8 +78,8 @@ ErrorCode ClientManagementLogic::getClientsList(const ServerCredentials &credent
|
|||
|
||||
if (mainProtocol == Proto::OpenVpn) {
|
||||
const QString getOpenVpnClientsList = "sudo docker exec -i $CONTAINER_NAME bash -c 'ls /opt/amnezia/openvpn/pki/issued'";
|
||||
QString script = m_serverController->replaceVars(getOpenVpnClientsList, m_serverController->genVarsForScript(credentials, container));
|
||||
error = m_serverController->runScript(credentials, script, cbReadStdOut);
|
||||
QString script = serverController.replaceVars(getOpenVpnClientsList, serverController.genVarsForScript(credentials, container));
|
||||
error = serverController.runScript(credentials, script, cbReadStdOut);
|
||||
if (error != ErrorCode::NoError) {
|
||||
return error;
|
||||
}
|
||||
|
|
@ -101,7 +103,7 @@ ErrorCode ClientManagementLogic::getClientsList(const ServerCredentials &credent
|
|||
}
|
||||
} else if (mainProtocol == Proto::WireGuard) {
|
||||
const QString wireGuardConfigFile = "opt/amnezia/wireguard/wg0.conf";
|
||||
const QString wireguardConfigString = m_serverController->getTextFileFromContainer(container, credentials, wireGuardConfigFile, &error);
|
||||
const QString wireguardConfigString = serverController.getTextFileFromContainer(container, credentials, wireGuardConfigFile, &error);
|
||||
if (error != ErrorCode::NoError) {
|
||||
return error;
|
||||
}
|
||||
|
|
@ -128,7 +130,7 @@ ErrorCode ClientManagementLogic::getClientsList(const ServerCredentials &credent
|
|||
|
||||
const QByteArray newClientsTableString = QJsonDocument(clientsTable).toJson();
|
||||
if (clientsTableString != newClientsTableString) {
|
||||
error = m_serverController->uploadTextFileToContainer(container, credentials, newClientsTableString, clientsTableFile);
|
||||
error = serverController.uploadTextFileToContainer(container, credentials, newClientsTableString, clientsTableFile);
|
||||
}
|
||||
|
||||
if (error != ErrorCode::NoError) {
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ GeneralSettingsLogic::GeneralSettingsLogic(UiLogic *logic, QObject *parent):
|
|||
void GeneralSettingsLogic::onUpdatePage()
|
||||
{
|
||||
uiLogic()->m_selectedServerIndex = m_settings->defaultServerIndex();
|
||||
set_existsAnyServer(uiLogic()->m_selectedServerIndex >= 0);
|
||||
set_existsAnyServer(m_settings->serversCount() > 0);
|
||||
uiLogic()->m_selectedDockerContainer = m_settings->defaultContainer(m_settings->defaultServerIndex());
|
||||
|
||||
set_pushButtonGeneralSettingsShareConnectionEnable(m_settings->haveAuthData(m_settings->defaultServerIndex()));
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ PageLogicBase::PageLogicBase(UiLogic *logic, QObject *parent):
|
|||
{
|
||||
m_settings = logic->m_settings;
|
||||
m_configurator = logic->m_configurator;
|
||||
m_serverController = logic->m_serverController;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ protected:
|
|||
|
||||
std::shared_ptr<Settings> m_settings;
|
||||
std::shared_ptr<VpnConfigurator> m_configurator;
|
||||
std::shared_ptr<ServerController> m_serverController;
|
||||
|
||||
signals:
|
||||
void updatePage();
|
||||
|
|
|
|||
|
|
@ -96,19 +96,18 @@ ErrorCode ServerConfiguringProgressLogic::doInstallAction(const std::function<Er
|
|||
progress.setValueFunc(0);
|
||||
timer.start(1000);
|
||||
|
||||
ServerController serverController(m_settings);
|
||||
|
||||
QMetaObject::Connection cancelDoInstallActionConnection;
|
||||
if (cancelButton.setVisibleFunc) {
|
||||
cancelDoInstallActionConnection = connect(this, &ServerConfiguringProgressLogic::cancelDoInstallAction,
|
||||
m_serverController.get(), &ServerController::setCancelInstallation);
|
||||
&serverController, &ServerController::setCancelInstallation);
|
||||
}
|
||||
|
||||
|
||||
QMetaObject::Connection serverBusyConnection;
|
||||
if (serverBusyInfo.setVisibleFunc && serverBusyInfo.setTextFunc) {
|
||||
serverBusyConnection = connect(m_serverController.get(),
|
||||
&ServerController::serverIsBusy,
|
||||
this,
|
||||
[&serverBusyInfo, &timer, &cancelButton](const bool isBusy) {
|
||||
auto onServerIsBusy = [&serverBusyInfo, &timer, &cancelButton](const bool isBusy) {
|
||||
isBusy ? timer.stop() : timer.start(1000);
|
||||
serverBusyInfo.setVisibleFunc(isBusy);
|
||||
serverBusyInfo.setTextFunc(isBusy ? "Amnesia has detected that your server is currently "
|
||||
|
|
@ -118,7 +117,9 @@ ErrorCode ServerConfiguringProgressLogic::doInstallAction(const std::function<Er
|
|||
if (cancelButton.setVisibleFunc) {
|
||||
cancelButton.setVisibleFunc(isBusy ? true : false);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
serverBusyConnection = connect(&serverController, &ServerController::serverIsBusy, this, onServerIsBusy);
|
||||
}
|
||||
|
||||
ErrorCode e = action();
|
||||
|
|
@ -182,5 +183,5 @@ ErrorCode ServerConfiguringProgressLogic::doInstallAction(const std::function<Er
|
|||
|
||||
void ServerConfiguringProgressLogic::onPushButtonCancelClicked()
|
||||
{
|
||||
cancelDoInstallAction(true);
|
||||
emit cancelDoInstallAction(true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,9 +4,7 @@
|
|||
|
||||
#include <QApplication>
|
||||
|
||||
#include "protocols/CloakLogic.h"
|
||||
#include "protocols/OpenVpnLogic.h"
|
||||
#include "protocols/ShadowSocksLogic.h"
|
||||
#include "protocols/PageProtocolLogicBase.h"
|
||||
|
||||
#include "core/servercontroller.h"
|
||||
#include <functional>
|
||||
|
|
@ -31,6 +29,7 @@ void ServerContainersLogic::onUpdatePage()
|
|||
p_model->setSelectedServerIndex(uiLogic()->m_selectedServerIndex);
|
||||
|
||||
set_isManagedServer(m_settings->haveAuthData(uiLogic()->m_selectedServerIndex));
|
||||
uiLogic()->m_installCredentials = m_settings->serverCredentials(uiLogic()->m_selectedServerIndex);
|
||||
emit updatePage();
|
||||
}
|
||||
|
||||
|
|
@ -69,7 +68,8 @@ void ServerContainersLogic::onPushButtonShareClicked(DockerContainer c)
|
|||
void ServerContainersLogic::onPushButtonRemoveClicked(DockerContainer container)
|
||||
{
|
||||
//buttonSetEnabledFunc(false);
|
||||
ErrorCode e = m_serverController->removeContainer(m_settings->serverCredentials(uiLogic()->m_selectedServerIndex), container);
|
||||
ServerController serverController(m_settings);
|
||||
ErrorCode e = serverController.removeContainer(m_settings->serverCredentials(uiLogic()->m_selectedServerIndex), container);
|
||||
m_settings->removeContainerConfig(uiLogic()->m_selectedServerIndex, container);
|
||||
//buttonSetEnabledFunc(true);
|
||||
|
||||
|
|
@ -83,18 +83,20 @@ void ServerContainersLogic::onPushButtonRemoveClicked(DockerContainer container)
|
|||
|
||||
void ServerContainersLogic::onPushButtonContinueClicked(DockerContainer c, int port, TransportProto tp)
|
||||
{
|
||||
QJsonObject config = m_serverController->createContainerInitialConfig(c, port, tp);
|
||||
ServerController serverController(m_settings);
|
||||
QJsonObject config = serverController.createContainerInitialConfig(c, port, tp);
|
||||
|
||||
emit uiLogic()->goToPage(Page::ServerConfiguringProgress);
|
||||
qApp->processEvents();
|
||||
|
||||
bool isServerCreated = false;
|
||||
ErrorCode errorCode = uiLogic()->addAlreadyInstalledContainersGui(false, isServerCreated);
|
||||
ErrorCode errorCode = uiLogic()->addAlreadyInstalledContainersGui(isServerCreated);
|
||||
|
||||
if (errorCode == ErrorCode::NoError) {
|
||||
if (!uiLogic()->isContainerAlreadyAddedToGui(c)) {
|
||||
auto installAction = [this, c, &config]() {
|
||||
return m_serverController->setupContainer(m_settings->serverCredentials(uiLogic()->m_selectedServerIndex), c, config);
|
||||
ServerController serverController(m_settings);
|
||||
return serverController.setupContainer(m_settings->serverCredentials(uiLogic()->m_selectedServerIndex), c, config);
|
||||
};
|
||||
errorCode = uiLogic()->pageLogic<ServerConfiguringProgressLogic>()->doInstallAction(installAction);
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ void ServerListLogic::onServerListPushbuttonDefaultClicked(int index)
|
|||
void ServerListLogic::onServerListPushbuttonSettingsClicked(int index)
|
||||
{
|
||||
uiLogic()->m_selectedServerIndex = index;
|
||||
uiLogic()->m_installCredentials = m_settings->serverCredentials(index);
|
||||
uiLogic()->goToPage(Page::ServerSettings);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,9 +6,11 @@
|
|||
#include "configurators/vpn_configurator.h"
|
||||
#include "../uilogic.h"
|
||||
#include "utilities.h"
|
||||
#include "core/servercontroller.h"
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QStandardPaths>
|
||||
#include <QEventLoop>
|
||||
|
||||
#ifdef Q_OS_ANDROID
|
||||
#include <QJniObject>
|
||||
|
|
@ -94,8 +96,7 @@ void StartPageLogic::onPushButtonConnect()
|
|||
set_labelWaitInfoText(tr("Please fill in all fields"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (lineEditIpText().isEmpty() ||
|
||||
lineEditLoginText().isEmpty() ||
|
||||
lineEditPasswordText().isEmpty() ) {
|
||||
|
|
@ -111,7 +112,7 @@ void StartPageLogic::onPushButtonConnect()
|
|||
serverCredentials.hostName = serverCredentials.hostName.split(":").at(0);
|
||||
}
|
||||
serverCredentials.userName = lineEditLoginText();
|
||||
if (pushButtonConnectKeyChecked()){
|
||||
if (pushButtonConnectKeyChecked()) {
|
||||
QString key = textEditSshKeyText();
|
||||
if (key.startsWith("ssh-rsa")) {
|
||||
emit uiLogic()->showPublicKeyWarning();
|
||||
|
|
@ -123,28 +124,44 @@ void StartPageLogic::onPushButtonConnect()
|
|||
}
|
||||
|
||||
serverCredentials.password = key;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
serverCredentials.password = lineEditPasswordText();
|
||||
}
|
||||
|
||||
set_pushButtonConnectEnabled(false);
|
||||
set_pushButtonConnectText(tr("Connecting..."));
|
||||
|
||||
ErrorCode e = ErrorCode::NoError;
|
||||
#ifdef Q_DEBUG
|
||||
//QString output = m_serverController->checkSshConnection(serverCredentials, &e);
|
||||
#else
|
||||
ServerController serverController(m_settings);
|
||||
ErrorCode errorCode = ErrorCode::NoError;
|
||||
|
||||
if (pushButtonConnectKeyChecked()) {
|
||||
auto passphraseCallback = [this, &serverController]() {
|
||||
emit showPassphraseRequestMessage();
|
||||
QEventLoop loop;
|
||||
QObject::connect(this, &StartPageLogic::passphraseDialogClosed, &loop, &QEventLoop::quit);
|
||||
loop.exec();
|
||||
|
||||
return m_privateKeyPassphrase;
|
||||
};
|
||||
|
||||
QString decryptedPrivateKey;
|
||||
errorCode = serverController.getDecryptedPrivateKey(serverCredentials, decryptedPrivateKey, passphraseCallback);
|
||||
if (errorCode == ErrorCode::NoError) {
|
||||
serverCredentials.password = decryptedPrivateKey;
|
||||
}
|
||||
}
|
||||
|
||||
QString output;
|
||||
#endif
|
||||
if (errorCode == ErrorCode::NoError) {
|
||||
output = serverController.checkSshConnection(serverCredentials, &errorCode);
|
||||
}
|
||||
|
||||
bool ok = true;
|
||||
if (e) {
|
||||
if (errorCode) {
|
||||
set_labelWaitInfoVisible(true);
|
||||
set_labelWaitInfoText(errorString(e));
|
||||
set_labelWaitInfoText(errorString(errorCode));
|
||||
ok = false;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (output.contains("Please login as the user")) {
|
||||
output.replace("\n", "");
|
||||
set_labelWaitInfoVisible(true);
|
||||
|
|
@ -167,7 +184,7 @@ void StartPageLogic::onPushButtonImport()
|
|||
|
||||
void StartPageLogic::onPushButtonImportOpenFile()
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(Q_NULLPTR, tr("Open config file"),
|
||||
QString fileName = UiLogic::getOpenFileName(Q_NULLPTR, tr("Open config file"),
|
||||
QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), "*.vpn *.ovpn *.conf");
|
||||
if (fileName.isEmpty()) return;
|
||||
|
||||
|
|
@ -175,14 +192,7 @@ void StartPageLogic::onPushButtonImportOpenFile()
|
|||
file.open(QIODevice::ReadOnly);
|
||||
QByteArray data = file.readAll();
|
||||
|
||||
auto configFormat = checkConfigFormat(QString(data));
|
||||
if (configFormat == ConfigTypes::OpenVpn) {
|
||||
importConnectionFromOpenVpnConfig(QString(data));
|
||||
} else if (configFormat == ConfigTypes::WireGuard) {
|
||||
importConnectionFromWireguardConfig(QString(data));
|
||||
} else {
|
||||
importConnectionFromCode(QString(data));
|
||||
}
|
||||
selectConfigFormat(QString(data));
|
||||
}
|
||||
|
||||
#ifdef Q_OS_ANDROID
|
||||
|
|
@ -192,6 +202,18 @@ void StartPageLogic::startQrDecoder()
|
|||
}
|
||||
#endif
|
||||
|
||||
void StartPageLogic::selectConfigFormat(QString configData)
|
||||
{
|
||||
auto configFormat = checkConfigFormat(configData);
|
||||
if (configFormat == ConfigTypes::OpenVpn) {
|
||||
importConnectionFromOpenVpnConfig(configData);
|
||||
} else if (configFormat == ConfigTypes::WireGuard) {
|
||||
importConnectionFromWireguardConfig(configData);
|
||||
} else {
|
||||
importConnectionFromCode(configData);
|
||||
}
|
||||
}
|
||||
|
||||
bool StartPageLogic::importConnection(const QJsonObject &profile)
|
||||
{
|
||||
ServerCredentials credentials;
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@ class StartPageLogic : public PageLogicBase
|
|||
AUTO_PROPERTY(QString, labelWaitInfoText)
|
||||
AUTO_PROPERTY(bool, pushButtonBackFromStartVisible)
|
||||
|
||||
AUTO_PROPERTY(QString, privateKeyPassphrase);
|
||||
|
||||
READONLY_PROPERTY(QRegularExpression, ipAddressPortRegex)
|
||||
public:
|
||||
Q_INVOKABLE void onUpdatePage() override;
|
||||
|
|
@ -35,6 +37,8 @@ public:
|
|||
Q_INVOKABLE void startQrDecoder();
|
||||
#endif
|
||||
|
||||
void selectConfigFormat(QString configData);
|
||||
|
||||
bool importConnection(const QJsonObject &profile);
|
||||
bool importConnectionFromCode(QString code);
|
||||
bool importConnectionFromQr(const QByteArray &data);
|
||||
|
|
@ -45,5 +49,8 @@ public:
|
|||
explicit StartPageLogic(UiLogic *uiLogic, QObject *parent = nullptr);
|
||||
~StartPageLogic() = default;
|
||||
|
||||
signals:
|
||||
void showPassphraseRequestMessage();
|
||||
void passphraseDialogClosed();
|
||||
};
|
||||
#endif // START_PAGE_LOGIC_H
|
||||
|
|
|
|||
|
|
@ -112,15 +112,16 @@ void CloakLogic::onPushButtonSaveClicked()
|
|||
|
||||
progressBarFunc.setTextVisibleFunc(true);
|
||||
progressBarFunc.setTextFunc(QString("Configuring..."));
|
||||
ErrorCode e = uiLogic()->pageLogic<ServerConfiguringProgressLogic>()->doInstallAction([this, containerConfig, &newContainerConfig](){
|
||||
return m_serverController->updateContainer(m_settings->serverCredentials(uiLogic()->m_selectedServerIndex),
|
||||
uiLogic()->m_selectedDockerContainer,
|
||||
containerConfig,
|
||||
newContainerConfig);
|
||||
},
|
||||
pageFunc, progressBarFunc,
|
||||
saveButtonFunc, waitInfoFunc,
|
||||
busyInfoFuncy, cancelButtonFunc);
|
||||
|
||||
auto installAction = [this, containerConfig, &newContainerConfig]() {
|
||||
ServerController serverController(m_settings);
|
||||
return serverController.updateContainer(m_settings->serverCredentials(uiLogic()->m_selectedServerIndex),
|
||||
uiLogic()->m_selectedDockerContainer, containerConfig, newContainerConfig);
|
||||
};
|
||||
|
||||
ErrorCode e = uiLogic()->pageLogic<ServerConfiguringProgressLogic>()->doInstallAction(installAction, pageFunc, progressBarFunc,
|
||||
saveButtonFunc, waitInfoFunc,
|
||||
busyInfoFuncy, cancelButtonFunc);
|
||||
|
||||
if (!e) {
|
||||
m_settings->setContainerConfig(uiLogic()->m_selectedServerIndex, uiLogic()->m_selectedDockerContainer, newContainerConfig);
|
||||
|
|
|
|||
|
|
@ -162,15 +162,16 @@ void OpenVpnLogic::onPushButtonSaveClicked()
|
|||
|
||||
progressBarFunc.setTextVisibleFunc(true);
|
||||
progressBarFunc.setTextFunc(QString("Configuring..."));
|
||||
ErrorCode e = uiLogic()->pageLogic<ServerConfiguringProgressLogic>()->doInstallAction([this, containerConfig, &newContainerConfig](){
|
||||
return m_serverController->updateContainer(m_settings->serverCredentials(uiLogic()->m_selectedServerIndex),
|
||||
uiLogic()->m_selectedDockerContainer,
|
||||
containerConfig,
|
||||
newContainerConfig);
|
||||
},
|
||||
pageFunc, progressBarFunc,
|
||||
saveButtonFunc, waitInfoFunc,
|
||||
busyInfoFuncy, cancelButtonFunc);
|
||||
|
||||
auto installAction = [this, containerConfig, &newContainerConfig]() {
|
||||
ServerController serverController(m_settings);
|
||||
return serverController.updateContainer(m_settings->serverCredentials(uiLogic()->m_selectedServerIndex),
|
||||
uiLogic()->m_selectedDockerContainer, containerConfig, newContainerConfig);
|
||||
};
|
||||
|
||||
ErrorCode e = uiLogic()->pageLogic<ServerConfiguringProgressLogic>()->doInstallAction(installAction, pageFunc, progressBarFunc,
|
||||
saveButtonFunc, waitInfoFunc,
|
||||
busyInfoFuncy, cancelButtonFunc);
|
||||
|
||||
if (!e) {
|
||||
m_settings->setContainerConfig(uiLogic()->m_selectedServerIndex, uiLogic()->m_selectedDockerContainer, newContainerConfig);
|
||||
|
|
|
|||
|
|
@ -104,15 +104,15 @@ void ShadowSocksLogic::onPushButtonSaveClicked()
|
|||
|
||||
progressBarFunc.setTextVisibleFunc(true);
|
||||
progressBarFunc.setTextFunc(QString("Configuring..."));
|
||||
ErrorCode e = uiLogic()->pageLogic<ServerConfiguringProgressLogic>()->doInstallAction([this, containerConfig, &newContainerConfig](){
|
||||
return m_serverController->updateContainer(m_settings->serverCredentials(uiLogic()->m_selectedServerIndex),
|
||||
uiLogic()->m_selectedDockerContainer,
|
||||
containerConfig,
|
||||
newContainerConfig);
|
||||
},
|
||||
pageFunc, progressBarFunc,
|
||||
saveButtonFunc, waitInfoFunc,
|
||||
busyInfoFuncy, cancelButtonFunc);
|
||||
|
||||
auto installAction = [this, containerConfig, &newContainerConfig]() {
|
||||
ServerController serverController(m_settings);
|
||||
return serverController.updateContainer(m_settings->serverCredentials(uiLogic()->m_selectedServerIndex),
|
||||
uiLogic()->m_selectedDockerContainer, containerConfig, newContainerConfig);
|
||||
};
|
||||
ErrorCode e = uiLogic()->pageLogic<ServerConfiguringProgressLogic>()->doInstallAction(installAction, pageFunc, progressBarFunc,
|
||||
saveButtonFunc, waitInfoFunc,
|
||||
busyInfoFuncy, cancelButtonFunc);
|
||||
|
||||
if (!e) {
|
||||
m_settings->setContainerConfig(uiLogic()->m_selectedServerIndex, uiLogic()->m_selectedDockerContainer, newContainerConfig);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue