Refresh killswitch mode when it toggled
This commit is contained in:
parent
1fa96a09a0
commit
7a3520cb20
8 changed files with 28 additions and 4 deletions
|
|
@ -457,6 +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);
|
||||
|
||||
m_sitesController.reset(new SitesController(m_settings, m_vpnConnection, m_sitesModel));
|
||||
m_engine->rootContext()->setContextProperty("SitesController", m_sitesController.get());
|
||||
|
|
|
|||
|
|
@ -52,6 +52,13 @@ void VpnConnection::onBytesChanged(quint64 receivedBytes, quint64 sentBytes)
|
|||
emit bytesChanged(receivedBytes, sentBytes);
|
||||
}
|
||||
|
||||
void VpnConnection::onKillswitchModeChanged()
|
||||
{
|
||||
#ifdef AMNEZIA_DESKTOP
|
||||
IpcClient::Interface()->refreshKillSwitch();
|
||||
#endif
|
||||
}
|
||||
|
||||
void VpnConnection::onConnectionStateChanged(Vpn::ConnectionState state)
|
||||
{
|
||||
|
||||
|
|
|
|||
|
|
@ -52,10 +52,10 @@ public slots:
|
|||
|
||||
void disconnectFromVpn();
|
||||
|
||||
|
||||
void addRoutes(const QStringList &ips);
|
||||
void deleteRoutes(const QStringList &ips);
|
||||
void flushDns();
|
||||
void onKillswitchModeChanged();
|
||||
|
||||
signals:
|
||||
void bytesChanged(quint64 receivedBytes, quint64 sentBytes);
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ class IpcInterface
|
|||
|
||||
SLOT( bool disableKillSwitch() );
|
||||
SLOT( bool disableAllTraffic() );
|
||||
SLOT( bool refreshKillSwitch() );
|
||||
SLOT( bool allowTrafficTo( const QStringList ranges ) );
|
||||
SLOT( bool enablePeerTraffic( const QJsonObject &configStr) );
|
||||
SLOT( bool enableKillSwitch( const QJsonObject &excludeAddr, int vpnAdapterIndex) );
|
||||
|
|
|
|||
|
|
@ -203,3 +203,8 @@ bool IpcServer::enablePeerTraffic(const QJsonObject &configStr)
|
|||
{
|
||||
return KillSwitch::instance()->enablePeerTraffic(configStr);
|
||||
}
|
||||
|
||||
bool IpcServer::refreshKillSwitch()
|
||||
{
|
||||
return KillSwitch::instance()->refresh();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,6 +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 updateResolvers(const QString& ifname, const QList<QHostAddress>& resolvers) override;
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -43,15 +43,24 @@ bool KillSwitch::init()
|
|||
MacOSFirewall::install();
|
||||
}
|
||||
#endif
|
||||
m_appSettigns = QSharedPointer<SecureQSettings>(new SecureQSettings(ORGANIZATION_NAME, APPLICATION_NAME, nullptr));
|
||||
if (isStrictKillSwitchEnabled()) {
|
||||
return disableAllTraffic();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool KillSwitch::refresh()
|
||||
{
|
||||
if (isStrictKillSwitchEnabled()) {
|
||||
return disableAllTraffic();
|
||||
} else {
|
||||
return disableKillSwitch();
|
||||
}
|
||||
}
|
||||
|
||||
bool KillSwitch::isStrictKillSwitchEnabled()
|
||||
{
|
||||
m_appSettigns = QSharedPointer<SecureQSettings>(new SecureQSettings(ORGANIZATION_NAME, APPLICATION_NAME, nullptr));
|
||||
return m_appSettigns->value("Conf/strictKillSwitchEnabled", false).toBool();
|
||||
}
|
||||
|
||||
|
|
@ -98,7 +107,6 @@ bool KillSwitch::disableKillSwitch() {
|
|||
#endif
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
bool KillSwitch::disableAllTraffic() {
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ class KillSwitch : public QObject
|
|||
public:
|
||||
static KillSwitch *instance();
|
||||
bool init();
|
||||
bool refresh();
|
||||
bool disableKillSwitch();
|
||||
bool disableAllTraffic();
|
||||
bool enablePeerTraffic( const QJsonObject &configStr);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue