Use HLM to store strictMode flag
This commit is contained in:
parent
7a3520cb20
commit
84d95477cb
10 changed files with 24 additions and 12 deletions
|
|
@ -457,7 +457,7 @@ void AmneziaApplication::initControllers()
|
|||
QTimer::singleShot(1000, this, [this]() { m_connectionController->openConnection(); });
|
||||
}
|
||||
connect(m_settingsController.get(), &SettingsController::amneziaDnsToggled, m_serversModel.get(), &ServersModel::toggleAmneziaDns);
|
||||
connect(m_settingsController.get(), &SettingsController::strictKillSwitchEnabledChanged, m_vpnConnection.get(), &VpnConnection::onKillswitchModeChanged);
|
||||
connect(m_settingsController.get(), &SettingsController::strictKillSwitchEnabledChanged, m_vpnConnection.get(), &VpnConnection::onKillSwitchModeChanged);
|
||||
|
||||
m_sitesController.reset(new SitesController(m_settings, m_vpnConnection, m_sitesModel));
|
||||
m_engine->rootContext()->setContextProperty("SitesController", m_sitesController.get());
|
||||
|
|
|
|||
|
|
@ -256,7 +256,7 @@ bool SettingsController::isStrictKillSwitchEnabled()
|
|||
void SettingsController::toggleStrictKillSwitch(bool enable)
|
||||
{
|
||||
m_settings->setStrictKillSwitchEnabled(enable);
|
||||
emit strictKillSwitchEnabledChanged();
|
||||
emit strictKillSwitchEnabledChanged(enable);
|
||||
}
|
||||
|
||||
bool SettingsController::isNotificationPermissionGranted()
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ signals:
|
|||
void secondaryDnsChanged();
|
||||
void loggingStateChanged();
|
||||
void killSwitchEnabledChanged();
|
||||
void strictKillSwitchEnabledChanged();
|
||||
void strictKillSwitchEnabledChanged(bool enabled);
|
||||
|
||||
void restoreBackupFinished();
|
||||
void changeSettingsFinished(const QString &finishedMessage);
|
||||
|
|
|
|||
|
|
@ -52,10 +52,12 @@ void VpnConnection::onBytesChanged(quint64 receivedBytes, quint64 sentBytes)
|
|||
emit bytesChanged(receivedBytes, sentBytes);
|
||||
}
|
||||
|
||||
void VpnConnection::onKillswitchModeChanged()
|
||||
void VpnConnection::onKillSwitchModeChanged(bool enabled)
|
||||
{
|
||||
#ifdef AMNEZIA_DESKTOP
|
||||
IpcClient::Interface()->refreshKillSwitch();
|
||||
if (IpcClient::Interface()) {
|
||||
IpcClient::Interface()->refreshKillSwitch(enabled);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ public slots:
|
|||
void addRoutes(const QStringList &ips);
|
||||
void deleteRoutes(const QStringList &ips);
|
||||
void flushDns();
|
||||
void onKillswitchModeChanged();
|
||||
void onKillSwitchModeChanged(bool enabled);
|
||||
|
||||
signals:
|
||||
void bytesChanged(quint64 receivedBytes, quint64 sentBytes);
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ class IpcInterface
|
|||
|
||||
SLOT( bool disableKillSwitch() );
|
||||
SLOT( bool disableAllTraffic() );
|
||||
SLOT( bool refreshKillSwitch() );
|
||||
SLOT( bool refreshKillSwitch( bool enabled ) );
|
||||
SLOT( bool allowTrafficTo( const QStringList ranges ) );
|
||||
SLOT( bool enablePeerTraffic( const QJsonObject &configStr) );
|
||||
SLOT( bool enableKillSwitch( const QJsonObject &excludeAddr, int vpnAdapterIndex) );
|
||||
|
|
|
|||
|
|
@ -204,7 +204,7 @@ bool IpcServer::enablePeerTraffic(const QJsonObject &configStr)
|
|||
return KillSwitch::instance()->enablePeerTraffic(configStr);
|
||||
}
|
||||
|
||||
bool IpcServer::refreshKillSwitch()
|
||||
bool IpcServer::refreshKillSwitch(bool enabled)
|
||||
{
|
||||
return KillSwitch::instance()->refresh();
|
||||
return KillSwitch::instance()->refresh(enabled);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ public:
|
|||
virtual bool enablePeerTraffic(const QJsonObject &configStr) override;
|
||||
virtual bool enableKillSwitch(const QJsonObject &excludeAddr, int vpnAdapterIndex) override;
|
||||
virtual bool disableKillSwitch() override;
|
||||
virtual bool refreshKillSwitch() override;
|
||||
virtual bool refreshKillSwitch( bool enabled ) override;
|
||||
virtual bool updateResolvers(const QString& ifname, const QList<QHostAddress>& resolvers) override;
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -49,8 +49,13 @@ bool KillSwitch::init()
|
|||
return true;
|
||||
}
|
||||
|
||||
bool KillSwitch::refresh()
|
||||
bool KillSwitch::refresh(bool enabled)
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
QSettings RegHLM("HKEY_LOCAL_MACHINE\\Software\\" + QString(ORGANIZATION_NAME)
|
||||
+ "\\" + QString(APPLICATION_NAME), QSettings::NativeFormat);
|
||||
RegHLM.setValue("strictKillSwitchEnabled", enabled);
|
||||
#endif
|
||||
if (isStrictKillSwitchEnabled()) {
|
||||
return disableAllTraffic();
|
||||
} else {
|
||||
|
|
@ -60,6 +65,11 @@ bool KillSwitch::refresh()
|
|||
|
||||
bool KillSwitch::isStrictKillSwitchEnabled()
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
QSettings RegHLM("HKEY_LOCAL_MACHINE\\Software\\" + QString(ORGANIZATION_NAME)
|
||||
+ "\\" + QString(APPLICATION_NAME), QSettings::NativeFormat);
|
||||
return RegHLM.value("strictKillSwitchEnabled", false).toBool();
|
||||
#endif
|
||||
m_appSettigns = QSharedPointer<SecureQSettings>(new SecureQSettings(ORGANIZATION_NAME, APPLICATION_NAME, nullptr));
|
||||
return m_appSettigns->value("Conf/strictKillSwitchEnabled", false).toBool();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ class KillSwitch : public QObject
|
|||
public:
|
||||
static KillSwitch *instance();
|
||||
bool init();
|
||||
bool refresh();
|
||||
bool refresh(bool enabled);
|
||||
bool disableKillSwitch();
|
||||
bool disableAllTraffic();
|
||||
bool enablePeerTraffic( const QJsonObject &configStr);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue