Merge pull request #325 from amnezia-vpn/bugfix/reconnectvpn_when_dc_changed
auto reconection when current-server's defaul container hase been cha…
This commit is contained in:
commit
32dda9b904
10 changed files with 36 additions and 26 deletions
|
|
@ -344,6 +344,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::currentContainerUpdated, m_connectionController.get(),
|
||||||
|
&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());
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ public:
|
||||||
bool isUpdate = false);
|
bool isUpdate = false);
|
||||||
ErrorCode updateContainer(const ServerCredentials &credentials, DockerContainer container,
|
ErrorCode updateContainer(const ServerCredentials &credentials, 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);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -118,6 +118,14 @@ void ConnectionController::onConnectionStateChanged(Vpn::ConnectionState state)
|
||||||
emit connectionStateChanged();
|
emit connectionStateChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ConnectionController::onCurrentContainerUpdated()
|
||||||
|
{
|
||||||
|
if (m_isConnected || m_isConnectionInProgress) {
|
||||||
|
emit reconnectWithUpdatedContainer(tr("Settings updated successfully, Reconnnection..."));
|
||||||
|
openConnection();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QString ConnectionController::connectionStateText() const
|
QString ConnectionController::connectionStateText() const
|
||||||
{
|
{
|
||||||
return m_connectionStateText;
|
return m_connectionStateText;
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,8 @@ public slots:
|
||||||
QString getLastConnectionError();
|
QString getLastConnectionError();
|
||||||
void onConnectionStateChanged(Vpn::ConnectionState state);
|
void onConnectionStateChanged(Vpn::ConnectionState state);
|
||||||
|
|
||||||
|
void onCurrentContainerUpdated();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void connectToVpn(int serverIndex, const ServerCredentials &credentials, DockerContainer container,
|
void connectToVpn(int serverIndex, const ServerCredentials &credentials, DockerContainer container,
|
||||||
const QJsonObject &containerConfig);
|
const QJsonObject &containerConfig);
|
||||||
|
|
@ -39,6 +41,7 @@ signals:
|
||||||
void connectionStateChanged();
|
void connectionStateChanged();
|
||||||
|
|
||||||
void connectionErrorOccurred(const QString &errorMessage);
|
void connectionErrorOccurred(const QString &errorMessage);
|
||||||
|
void reconnectWithUpdatedContainer(const QString &message);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QSharedPointer<ServersModel> m_serversModel;
|
QSharedPointer<ServersModel> m_serversModel;
|
||||||
|
|
|
||||||
|
|
@ -259,7 +259,13 @@ void InstallController::updateContainer(QJsonObject config)
|
||||||
m_containersModel->setData(modelIndex, config, ContainersModel::Roles::ConfigRole);
|
m_containersModel->setData(modelIndex, config, ContainersModel::Roles::ConfigRole);
|
||||||
m_protocolModel->updateModel(config);
|
m_protocolModel->updateModel(config);
|
||||||
|
|
||||||
emit updateContainerFinished();
|
if ((serverIndex == m_serversModel->getDefaultServerIndex())
|
||||||
|
&& (container == m_containersModel->getDefaultContainer())) {
|
||||||
|
emit currentContainerUpdated();
|
||||||
|
} else {
|
||||||
|
emit updateContainerFinished(tr("Settings updated successfully"));
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ signals:
|
||||||
void installContainerFinished(const QString &finishMessage, bool isServiceInstall);
|
void installContainerFinished(const QString &finishMessage, bool isServiceInstall);
|
||||||
void installServerFinished(const QString &finishMessage);
|
void installServerFinished(const QString &finishMessage);
|
||||||
|
|
||||||
void updateContainerFinished();
|
void updateContainerFinished(const QString& message);
|
||||||
|
|
||||||
void scanServerFinished(bool isInstalledContainerFound);
|
void scanServerFinished(bool isInstalledContainerFound);
|
||||||
|
|
||||||
|
|
@ -66,6 +66,8 @@ signals:
|
||||||
|
|
||||||
void serverIsBusy(const bool isBusy);
|
void serverIsBusy(const bool isBusy);
|
||||||
|
|
||||||
|
void currentContainerUpdated();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void installServer(DockerContainer container, QJsonObject &config);
|
void installServer(DockerContainer container, QJsonObject &config);
|
||||||
void installContainer(DockerContainer container, QJsonObject &config);
|
void installContainer(DockerContainer container, QJsonObject &config);
|
||||||
|
|
|
||||||
|
|
@ -13,14 +13,6 @@ import "../Components"
|
||||||
PageType {
|
PageType {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
Connections {
|
|
||||||
target: InstallController
|
|
||||||
|
|
||||||
function onUpdateContainerFinished() {
|
|
||||||
PageController.showNotificationMessage(qsTr("Settings updated successfully"))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
id: backButton
|
id: backButton
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,14 +15,6 @@ import "../Components"
|
||||||
PageType {
|
PageType {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
Connections {
|
|
||||||
target: InstallController
|
|
||||||
|
|
||||||
function onUpdateContainerFinished() {
|
|
||||||
PageController.showNotificationMessage(qsTr("Settings updated successfully"))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
id: backButton
|
id: backButton
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,14 +13,6 @@ import "../Components"
|
||||||
PageType {
|
PageType {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
Connections {
|
|
||||||
target: InstallController
|
|
||||||
|
|
||||||
function onUpdateContainerFinished() {
|
|
||||||
PageController.showNotificationMessage(qsTr("Settings updated successfully"))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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