parent
9f82b4c21f
commit
e646b85e56
29 changed files with 512 additions and 56 deletions
|
|
@ -10,6 +10,8 @@
|
|||
#include "core/errorstrings.h"
|
||||
#include "core/controllers/serverController.h"
|
||||
#include "utilities.h"
|
||||
#include "ui/models/protocols/awgConfigModel.h"
|
||||
#include "ui/models/protocols/wireguardConfigModel.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
|
|
@ -273,12 +275,16 @@ void InstallController::updateContainer(QJsonObject config)
|
|||
|
||||
const DockerContainer container = ContainerProps::containerFromString(config.value(config_key::container).toString());
|
||||
QJsonObject oldContainerConfig = m_containersModel->getContainerConfig(container);
|
||||
ErrorCode errorCode = ErrorCode::NoError;
|
||||
|
||||
ServerController serverController(m_settings);
|
||||
connect(&serverController, &ServerController::serverIsBusy, this, &InstallController::serverIsBusy);
|
||||
connect(this, &InstallController::cancelInstallation, &serverController, &ServerController::cancelInstallation);
|
||||
if (isUpdateDockerContainerRequired(container, oldContainerConfig, config)) {
|
||||
ServerController serverController(m_settings);
|
||||
connect(&serverController, &ServerController::serverIsBusy, this, &InstallController::serverIsBusy);
|
||||
connect(this, &InstallController::cancelInstallation, &serverController, &ServerController::cancelInstallation);
|
||||
|
||||
errorCode = serverController.updateContainer(serverCredentials, container, oldContainerConfig, config);
|
||||
}
|
||||
|
||||
auto errorCode = serverController.updateContainer(serverCredentials, container, oldContainerConfig, config);
|
||||
if (errorCode == ErrorCode::NoError) {
|
||||
m_serversModel->updateContainerConfig(container, config);
|
||||
m_protocolModel->updateModel(config);
|
||||
|
|
@ -514,3 +520,29 @@ void InstallController::addEmptyServer()
|
|||
|
||||
emit installServerFinished(tr("Server added successfully"));
|
||||
}
|
||||
|
||||
bool InstallController::isUpdateDockerContainerRequired(const DockerContainer container, const QJsonObject &oldConfig, const QJsonObject &newConfig)
|
||||
{
|
||||
Proto mainProto = ContainerProps::defaultProtocol(container);
|
||||
|
||||
const QJsonObject &oldProtoConfig = oldConfig.value(ProtocolProps::protoToString(mainProto)).toObject();
|
||||
const QJsonObject &newProtoConfig = newConfig.value(ProtocolProps::protoToString(mainProto)).toObject();
|
||||
|
||||
if (container == DockerContainer::Awg) {
|
||||
const AwgConfig oldConfig(oldProtoConfig);
|
||||
const AwgConfig newConfig(newProtoConfig);
|
||||
|
||||
if (!oldConfig.hasEqualServerSettings(newConfig)) {
|
||||
return true;
|
||||
}
|
||||
} else if (container == DockerContainer::WireGuard) {
|
||||
const WgConfig oldConfig(oldProtoConfig);
|
||||
const WgConfig newConfig(newProtoConfig);
|
||||
|
||||
if (!oldConfig.hasEqualServerSettings(newConfig)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue