added reconnection to vpn after changing any protocol settings
This commit is contained in:
parent
bfc8c10f3d
commit
c0cb5b96bf
11 changed files with 33 additions and 79 deletions
|
@ -336,8 +336,8 @@ void AmneziaApplication::initControllers()
|
||||||
&PageController::showPassphraseRequestDrawer);
|
&PageController::showPassphraseRequestDrawer);
|
||||||
connect(m_pageController.get(), &PageController::passphraseRequestDrawerClosed, m_installController.get(),
|
connect(m_pageController.get(), &PageController::passphraseRequestDrawerClosed, m_installController.get(),
|
||||||
&InstallController::setEncryptedPassphrase);
|
&InstallController::setEncryptedPassphrase);
|
||||||
connect(m_installController.get(), &InstallController::currentContainerChanged, m_connectionController.get(),
|
connect(m_installController.get(), &InstallController::currentContainerUpdated, m_connectionController.get(),
|
||||||
&ConnectionController::onCurrentContainerChanged);
|
&ConnectionController::onCurrentContainerUpdated);
|
||||||
|
|
||||||
m_importController.reset(new ImportController(m_serversModel, m_containersModel, m_settings));
|
m_importController.reset(new ImportController(m_serversModel, m_containersModel, m_settings));
|
||||||
m_engine->rootContext()->setContextProperty("ImportController", m_importController.get());
|
m_engine->rootContext()->setContextProperty("ImportController", m_importController.get());
|
||||||
|
|
|
@ -290,11 +290,13 @@ ErrorCode ServerController::setupContainer(const ServerCredentials &credentials,
|
||||||
return startupContainerWorker(credentials, container, config);
|
return startupContainerWorker(credentials, container, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorCode ServerController::updateContainer(const bool reinstallRequired,
|
ErrorCode ServerController::updateContainer(const ServerCredentials &credentials, DockerContainer container,
|
||||||
const ServerCredentials &credentials,
|
|
||||||
DockerContainer container,
|
|
||||||
const QJsonObject &oldConfig, QJsonObject &newConfig)
|
const QJsonObject &oldConfig, QJsonObject &newConfig)
|
||||||
{
|
{
|
||||||
|
bool reinstallRequired = isReinstallContainerRequired(container, oldConfig, newConfig);
|
||||||
|
qDebug() << "ServerController::updateContainer for container" << container << "reinstall required is"
|
||||||
|
<< reinstallRequired;
|
||||||
|
|
||||||
if (reinstallRequired) {
|
if (reinstallRequired) {
|
||||||
return setupContainer(credentials, container, newConfig, true);
|
return setupContainer(credentials, container, newConfig, true);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -26,10 +26,8 @@ public:
|
||||||
ErrorCode removeContainer(const ServerCredentials &credentials, DockerContainer container);
|
ErrorCode removeContainer(const ServerCredentials &credentials, DockerContainer container);
|
||||||
ErrorCode setupContainer(const ServerCredentials &credentials, DockerContainer container, QJsonObject &config,
|
ErrorCode setupContainer(const ServerCredentials &credentials, DockerContainer container, QJsonObject &config,
|
||||||
bool isUpdate = false);
|
bool isUpdate = false);
|
||||||
ErrorCode updateContainer(const bool reinstallRequired, const ServerCredentials &credentials,
|
ErrorCode updateContainer(const ServerCredentials &credentials, DockerContainer container,
|
||||||
DockerContainer container,
|
const QJsonObject &oldConfig, QJsonObject &newConfig);
|
||||||
const QJsonObject &oldConfig,
|
|
||||||
QJsonObject &newConfig);
|
|
||||||
|
|
||||||
ErrorCode getAlreadyInstalledContainers(const ServerCredentials &credentials,
|
ErrorCode getAlreadyInstalledContainers(const ServerCredentials &credentials,
|
||||||
QMap<DockerContainer, QJsonObject> &installedContainers);
|
QMap<DockerContainer, QJsonObject> &installedContainers);
|
||||||
|
@ -63,8 +61,6 @@ public:
|
||||||
ErrorCode getDecryptedPrivateKey(const ServerCredentials &credentials, QString &decryptedPrivateKey,
|
ErrorCode getDecryptedPrivateKey(const ServerCredentials &credentials, QString &decryptedPrivateKey,
|
||||||
const std::function<QString()> &callback);
|
const std::function<QString()> &callback);
|
||||||
|
|
||||||
bool isReinstallContainerRequired(DockerContainer container, const QJsonObject &oldConfig,
|
|
||||||
const QJsonObject &newConfig);
|
|
||||||
private:
|
private:
|
||||||
ErrorCode installDockerWorker(const ServerCredentials &credentials, DockerContainer container);
|
ErrorCode installDockerWorker(const ServerCredentials &credentials, DockerContainer container);
|
||||||
ErrorCode prepareHostWorker(const ServerCredentials &credentials, DockerContainer container,
|
ErrorCode prepareHostWorker(const ServerCredentials &credentials, DockerContainer container,
|
||||||
|
@ -77,7 +73,8 @@ private:
|
||||||
|
|
||||||
ErrorCode isServerPortBusy(const ServerCredentials &credentials, DockerContainer container,
|
ErrorCode isServerPortBusy(const ServerCredentials &credentials, DockerContainer container,
|
||||||
const QJsonObject &config);
|
const QJsonObject &config);
|
||||||
|
bool isReinstallContainerRequired(DockerContainer container, const QJsonObject &oldConfig,
|
||||||
|
const QJsonObject &newConfig);
|
||||||
ErrorCode isUserInSudo(const ServerCredentials &credentials, DockerContainer container);
|
ErrorCode isUserInSudo(const ServerCredentials &credentials, DockerContainer container);
|
||||||
ErrorCode isServerDpkgBusy(const ServerCredentials &credentials, DockerContainer container);
|
ErrorCode isServerDpkgBusy(const ServerCredentials &credentials, DockerContainer container);
|
||||||
|
|
||||||
|
|
|
@ -118,10 +118,10 @@ void ConnectionController::onConnectionStateChanged(Vpn::ConnectionState state)
|
||||||
emit connectionStateChanged();
|
emit connectionStateChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConnectionController::onCurrentContainerChanged()
|
void ConnectionController::onCurrentContainerUpdated()
|
||||||
{
|
{
|
||||||
if(m_isConnected || m_isConnectionInProgress) {
|
if (m_isConnected || m_isConnectionInProgress) {
|
||||||
emit reconnectWithChangedContainer(tr("Settings updated successfully, Reconnnection..."));
|
emit reconnectWithUpdatedContainer(tr("Settings updated successfully, Reconnnection..."));
|
||||||
openConnection();
|
openConnection();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ public slots:
|
||||||
QString getLastConnectionError();
|
QString getLastConnectionError();
|
||||||
void onConnectionStateChanged(Vpn::ConnectionState state);
|
void onConnectionStateChanged(Vpn::ConnectionState state);
|
||||||
|
|
||||||
void onCurrentContainerChanged();
|
void onCurrentContainerUpdated();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void connectToVpn(int serverIndex, const ServerCredentials &credentials, DockerContainer container,
|
void connectToVpn(int serverIndex, const ServerCredentials &credentials, DockerContainer container,
|
||||||
|
@ -41,7 +41,7 @@ signals:
|
||||||
void connectionStateChanged();
|
void connectionStateChanged();
|
||||||
|
|
||||||
void connectionErrorOccurred(const QString &errorMessage);
|
void connectionErrorOccurred(const QString &errorMessage);
|
||||||
void reconnectWithChangedContainer(const QString &message);
|
void reconnectWithUpdatedContainer(const QString &message);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QSharedPointer<ServersModel> m_serversModel;
|
QSharedPointer<ServersModel> m_serversModel;
|
||||||
|
|
|
@ -254,22 +254,14 @@ void InstallController::updateContainer(QJsonObject config)
|
||||||
ServerController serverController(m_settings);
|
ServerController serverController(m_settings);
|
||||||
connect(&serverController, &ServerController::serverIsBusy, this, &InstallController::serverIsBusy);
|
connect(&serverController, &ServerController::serverIsBusy, this, &InstallController::serverIsBusy);
|
||||||
|
|
||||||
bool reinstallRequired = serverController.isReinstallContainerRequired(container, oldContainerConfig, config);
|
auto errorCode = serverController.updateContainer(serverCredentials, container, oldContainerConfig, config);
|
||||||
auto errorCode = serverController.updateContainer(reinstallRequired, serverCredentials, container, oldContainerConfig, config);
|
|
||||||
if (errorCode == ErrorCode::NoError) {
|
if (errorCode == ErrorCode::NoError) {
|
||||||
m_containersModel->setData(modelIndex, config, ContainersModel::Roles::ConfigRole);
|
m_containersModel->setData(modelIndex, config, ContainersModel::Roles::ConfigRole);
|
||||||
m_protocolModel->updateModel(config);
|
m_protocolModel->updateModel(config);
|
||||||
|
|
||||||
bool isCurrentContainerChanged = false;
|
if ((serverIndex == m_serversModel->getDefaultServerIndex())
|
||||||
if (reinstallRequired &&
|
&& (container == m_containersModel->getDefaultContainer())) {
|
||||||
(serverIndex == m_serversModel->getDefaultServerIndex()) &&
|
emit currentContainerUpdated();
|
||||||
(container == m_containersModel->getDefaultContainer()) ) {
|
|
||||||
isCurrentContainerChanged = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (isCurrentContainerChanged) {
|
|
||||||
emit currentContainerChanged();
|
|
||||||
} else {
|
} else {
|
||||||
emit updateContainerFinished(tr("Settings updated successfully"));
|
emit updateContainerFinished(tr("Settings updated successfully"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,7 @@ signals:
|
||||||
|
|
||||||
void serverIsBusy(const bool isBusy);
|
void serverIsBusy(const bool isBusy);
|
||||||
|
|
||||||
void currentContainerChanged();
|
void currentContainerUpdated();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void installServer(DockerContainer container, QJsonObject &config);
|
void installServer(DockerContainer container, QJsonObject &config);
|
||||||
|
|
|
@ -13,22 +13,6 @@ import "../Components"
|
||||||
PageType {
|
PageType {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
Connections {
|
|
||||||
target: ConnectionController
|
|
||||||
|
|
||||||
function onReconnectWithChangedContainer(message) {
|
|
||||||
PageController.showNotificationMessage(message)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Connections {
|
|
||||||
target: InstallController
|
|
||||||
|
|
||||||
function onUpdateContainerFinished(message) {
|
|
||||||
PageController.showNotificationMessage(message)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
id: backButton
|
id: backButton
|
||||||
|
|
||||||
|
|
|
@ -15,22 +15,6 @@ import "../Components"
|
||||||
PageType {
|
PageType {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
Connections {
|
|
||||||
target: ConnectionController
|
|
||||||
|
|
||||||
function onReconnectWithChangedContainer(message) {
|
|
||||||
PageController.showNotificationMessage(message)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Connections {
|
|
||||||
target: InstallController
|
|
||||||
|
|
||||||
function onUpdateContainerFinished(message) {
|
|
||||||
PageController.showNotificationMessage(message)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
id: backButton
|
id: backButton
|
||||||
|
|
||||||
|
|
|
@ -13,23 +13,6 @@ import "../Components"
|
||||||
PageType {
|
PageType {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
|
|
||||||
Connections {
|
|
||||||
target: ConnectionController
|
|
||||||
|
|
||||||
function onReconnectWithChangedContainer(message) {
|
|
||||||
PageController.showNotificationMessage(message)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Connections {
|
|
||||||
target: InstallController
|
|
||||||
|
|
||||||
function onUpdateContainerFinished(message) {
|
|
||||||
PageController.showNotificationMessage(message)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
id: backButton
|
id: backButton
|
||||||
|
|
||||||
|
|
|
@ -82,6 +82,18 @@ PageType {
|
||||||
PageController.closePage()
|
PageController.closePage()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onUpdateContainerFinished(message) {
|
||||||
|
PageController.showNotificationMessage(message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: ConnectionController
|
||||||
|
|
||||||
|
function onReconnectWithUpdatedContainer(message) {
|
||||||
|
PageController.showNotificationMessage(message)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
StackViewType {
|
StackViewType {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue