diff --git a/client/vpnconnection.cpp b/client/vpnconnection.cpp index 3e3ef23b..474bd887 100644 --- a/client/vpnconnection.cpp +++ b/client/vpnconnection.cpp @@ -55,7 +55,20 @@ void VpnConnection::onBytesChanged(quint64 receivedBytes, quint64 sentBytes) void VpnConnection::onKillSwitchModeChanged(bool enabled) { #ifdef AMNEZIA_DESKTOP + if (!m_IpcClient) { + m_IpcClient = new IpcClient(this); + } + + if (!m_IpcClient->isSocketConnected()) { + if (!IpcClient::init(m_IpcClient)) { + qWarning() << "Error occurred when init IPC client"; + emit serviceIsNotReady(); + return; + } + } + if (IpcClient::Interface()) { + qDebug() << "Set KillSwitch Strict mode enabled " << enabled; IpcClient::Interface()->refreshKillSwitch(enabled); } #endif diff --git a/service/server/killswitch.cpp b/service/server/killswitch.cpp index 24e162aa..ae4462a6 100644 --- a/service/server/killswitch.cpp +++ b/service/server/killswitch.cpp @@ -37,15 +37,18 @@ bool KillSwitch::init() if (!LinuxFirewall::isInstalled()) { LinuxFirewall::install(); } + m_appSettigns = QSharedPointer(new SecureQSettings(ORGANIZATION_NAME, APPLICATION_NAME, nullptr)); #endif #ifdef Q_OS_MACOS if (!MacOSFirewall::isInstalled()) { MacOSFirewall::install(); } + m_appSettigns = QSharedPointer(new SecureQSettings(ORGANIZATION_NAME, APPLICATION_NAME, nullptr)); #endif if (isStrictKillSwitchEnabled()) { return disableAllTraffic(); } + return true; } @@ -56,6 +59,9 @@ bool KillSwitch::refresh(bool enabled) + "\\" + QString(APPLICATION_NAME), QSettings::NativeFormat); RegHLM.setValue("strictKillSwitchEnabled", enabled); #endif + + m_appSettigns->setValue("Conf/strictKillSwitchEnabled", enabled); + if (isStrictKillSwitchEnabled()) { return disableAllTraffic(); } else { @@ -70,7 +76,7 @@ bool KillSwitch::isStrictKillSwitchEnabled() + "\\" + QString(APPLICATION_NAME), QSettings::NativeFormat); return RegHLM.value("strictKillSwitchEnabled", false).toBool(); #endif - m_appSettigns = QSharedPointer(new SecureQSettings(ORGANIZATION_NAME, APPLICATION_NAME, nullptr)); + m_appSettigns->sync(); return m_appSettigns->value("Conf/strictKillSwitchEnabled", false).toBool(); }