feature: Add Kill Switch settings page with strict mode option
This commit is contained in:
parent
5fc80121b4
commit
4407e2801b
9 changed files with 155 additions and 18 deletions
|
|
@ -197,6 +197,7 @@
|
||||||
<file>ui/qml/Pages2/PageSettingsBackup.qml</file>
|
<file>ui/qml/Pages2/PageSettingsBackup.qml</file>
|
||||||
<file>ui/qml/Pages2/PageSettingsConnection.qml</file>
|
<file>ui/qml/Pages2/PageSettingsConnection.qml</file>
|
||||||
<file>ui/qml/Pages2/PageSettingsDns.qml</file>
|
<file>ui/qml/Pages2/PageSettingsDns.qml</file>
|
||||||
|
<file>ui/qml/Pages2/PageSettingsKillSwitch.qml</file>
|
||||||
<file>ui/qml/Pages2/PageSettingsLogging.qml</file>
|
<file>ui/qml/Pages2/PageSettingsLogging.qml</file>
|
||||||
<file>ui/qml/Pages2/PageSettingsServerData.qml</file>
|
<file>ui/qml/Pages2/PageSettingsServerData.qml</file>
|
||||||
<file>ui/qml/Pages2/PageSettingsServerInfo.qml</file>
|
<file>ui/qml/Pages2/PageSettingsServerInfo.qml</file>
|
||||||
|
|
|
||||||
|
|
@ -443,6 +443,16 @@ void Settings::setKillSwitchEnabled(bool enabled)
|
||||||
setValue("Conf/killSwitchEnabled", enabled);
|
setValue("Conf/killSwitchEnabled", enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Settings::isStrictKillSwitchEnabled() const
|
||||||
|
{
|
||||||
|
return value("Conf/strictKillSwitchEnabled", false).toBool();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Settings::setStrictKillSwitchEnabled(bool enabled)
|
||||||
|
{
|
||||||
|
setValue("Conf/strictKillSwitchEnabled", enabled);
|
||||||
|
}
|
||||||
|
|
||||||
QString Settings::getInstallationUuid(const bool needCreate)
|
QString Settings::getInstallationUuid(const bool needCreate)
|
||||||
{
|
{
|
||||||
auto uuid = value("Conf/installationUuid", "").toString();
|
auto uuid = value("Conf/installationUuid", "").toString();
|
||||||
|
|
|
||||||
|
|
@ -213,6 +213,10 @@ public:
|
||||||
|
|
||||||
bool isKillSwitchEnabled() const;
|
bool isKillSwitchEnabled() const;
|
||||||
void setKillSwitchEnabled(bool enabled);
|
void setKillSwitchEnabled(bool enabled);
|
||||||
|
|
||||||
|
bool isStrictKillSwitchEnabled() const;
|
||||||
|
void setStrictKillSwitchEnabled(bool enabled);
|
||||||
|
|
||||||
QString getInstallationUuid(const bool needCreate);
|
QString getInstallationUuid(const bool needCreate);
|
||||||
|
|
||||||
void resetGatewayEndpoint();
|
void resetGatewayEndpoint();
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ namespace PageLoader
|
||||||
PageSettingsLogging,
|
PageSettingsLogging,
|
||||||
PageSettingsSplitTunneling,
|
PageSettingsSplitTunneling,
|
||||||
PageSettingsAppSplitTunneling,
|
PageSettingsAppSplitTunneling,
|
||||||
|
PageSettingsKillSwitch,
|
||||||
|
|
||||||
PageServiceSftpSettings,
|
PageServiceSftpSettings,
|
||||||
PageServiceTorWebsiteSettings,
|
PageServiceTorWebsiteSettings,
|
||||||
|
|
|
||||||
|
|
@ -245,6 +245,18 @@ bool SettingsController::isKillSwitchEnabled()
|
||||||
void SettingsController::toggleKillSwitch(bool enable)
|
void SettingsController::toggleKillSwitch(bool enable)
|
||||||
{
|
{
|
||||||
m_settings->setKillSwitchEnabled(enable);
|
m_settings->setKillSwitchEnabled(enable);
|
||||||
|
emit killSwitchEnabledChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SettingsController::isStrictKillSwitchEnabled()
|
||||||
|
{
|
||||||
|
return m_settings->isStrictKillSwitchEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsController::toggleStrictKillSwitch(bool enable)
|
||||||
|
{
|
||||||
|
m_settings->setStrictKillSwitchEnabled(enable);
|
||||||
|
emit strictKillSwitchEnabledChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SettingsController::isNotificationPermissionGranted()
|
bool SettingsController::isNotificationPermissionGranted()
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,8 @@ public:
|
||||||
Q_PROPERTY(QString secondaryDns READ getSecondaryDns WRITE setSecondaryDns NOTIFY secondaryDnsChanged)
|
Q_PROPERTY(QString secondaryDns READ getSecondaryDns WRITE setSecondaryDns NOTIFY secondaryDnsChanged)
|
||||||
Q_PROPERTY(bool isLoggingEnabled READ isLoggingEnabled WRITE toggleLogging NOTIFY loggingStateChanged)
|
Q_PROPERTY(bool isLoggingEnabled READ isLoggingEnabled WRITE toggleLogging NOTIFY loggingStateChanged)
|
||||||
Q_PROPERTY(bool isNotificationPermissionGranted READ isNotificationPermissionGranted NOTIFY onNotificationStateChanged)
|
Q_PROPERTY(bool isNotificationPermissionGranted READ isNotificationPermissionGranted NOTIFY onNotificationStateChanged)
|
||||||
|
Q_PROPERTY(bool isKillSwitchEnabled READ isKillSwitchEnabled WRITE toggleKillSwitch NOTIFY killSwitchEnabledChanged)
|
||||||
|
Q_PROPERTY(bool strictKillSwitchEnabled READ isStrictKillSwitchEnabled WRITE toggleStrictKillSwitch NOTIFY strictKillSwitchEnabledChanged)
|
||||||
|
|
||||||
Q_PROPERTY(bool isDevModeEnabled READ isDevModeEnabled NOTIFY devModeEnabled)
|
Q_PROPERTY(bool isDevModeEnabled READ isDevModeEnabled NOTIFY devModeEnabled)
|
||||||
Q_PROPERTY(QString gatewayEndpoint READ getGatewayEndpoint WRITE setGatewayEndpoint NOTIFY gatewayEndpointChanged)
|
Q_PROPERTY(QString gatewayEndpoint READ getGatewayEndpoint WRITE setGatewayEndpoint NOTIFY gatewayEndpointChanged)
|
||||||
|
|
@ -73,6 +75,9 @@ public slots:
|
||||||
bool isKillSwitchEnabled();
|
bool isKillSwitchEnabled();
|
||||||
void toggleKillSwitch(bool enable);
|
void toggleKillSwitch(bool enable);
|
||||||
|
|
||||||
|
bool isStrictKillSwitchEnabled();
|
||||||
|
void toggleStrictKillSwitch(bool enable);
|
||||||
|
|
||||||
bool isNotificationPermissionGranted();
|
bool isNotificationPermissionGranted();
|
||||||
void requestNotificationPermission();
|
void requestNotificationPermission();
|
||||||
|
|
||||||
|
|
@ -93,6 +98,8 @@ signals:
|
||||||
void primaryDnsChanged();
|
void primaryDnsChanged();
|
||||||
void secondaryDnsChanged();
|
void secondaryDnsChanged();
|
||||||
void loggingStateChanged();
|
void loggingStateChanged();
|
||||||
|
void killSwitchEnabledChanged();
|
||||||
|
void strictKillSwitchEnabledChanged();
|
||||||
|
|
||||||
void restoreBackupFinished();
|
void restoreBackupFinished();
|
||||||
void changeSettingsFinished(const QString &finishedMessage);
|
void changeSettingsFinished(const QString &finishedMessage);
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,11 @@ Item {
|
||||||
|
|
||||||
property string actionButtonImage
|
property string actionButtonImage
|
||||||
property var actionButtonFunction
|
property var actionButtonFunction
|
||||||
|
property var switcherFunction
|
||||||
|
property bool showSwitcher: false
|
||||||
|
|
||||||
property alias actionButton: headerActionButton
|
property alias actionButton: headerActionButton
|
||||||
|
property alias switcher: headerSwitcher
|
||||||
|
|
||||||
property string headerText
|
property string headerText
|
||||||
property int headerTextMaximumLineCount: 2
|
property int headerTextMaximumLineCount: 2
|
||||||
|
|
@ -56,6 +59,18 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SwitcherType {
|
||||||
|
id: headerSwitcher
|
||||||
|
Layout.alignment: Qt.AlignRight
|
||||||
|
visible: root.showSwitcher
|
||||||
|
|
||||||
|
onToggled: {
|
||||||
|
if (switcherFunction && typeof switcherFunction === "function") {
|
||||||
|
switcherFunction(checked)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ParagraphTextType {
|
ParagraphTextType {
|
||||||
|
|
|
||||||
|
|
@ -94,9 +94,7 @@ PageType {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DividerType {
|
DividerType {}
|
||||||
visible: root.isAppSplitTinnelingEnabled
|
|
||||||
}
|
|
||||||
|
|
||||||
LabelWithButtonType {
|
LabelWithButtonType {
|
||||||
id: splitTunnelingButton2
|
id: splitTunnelingButton2
|
||||||
|
|
@ -119,29 +117,20 @@ PageType {
|
||||||
visible: root.isAppSplitTinnelingEnabled
|
visible: root.isAppSplitTinnelingEnabled
|
||||||
}
|
}
|
||||||
|
|
||||||
SwitcherType {
|
LabelWithButtonType {
|
||||||
id: killSwitchSwitcher
|
id: killSwitchButton
|
||||||
visible: !GC.isMobile()
|
visible: !GC.isMobile()
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.margins: 16
|
|
||||||
|
|
||||||
text: qsTr("KillSwitch")
|
text: qsTr("KillSwitch")
|
||||||
descriptionText: qsTr("Disables your internet if your encrypted VPN connection drops out for any reason.")
|
descriptionText: qsTr("Blocks network connections without VPN")
|
||||||
|
rightImageSource: "qrc:/images/controls/chevron-right.svg"
|
||||||
|
|
||||||
parentFlickable: fl
|
parentFlickable: fl
|
||||||
|
|
||||||
checked: SettingsController.isKillSwitchEnabled()
|
clickedFunction: function() {
|
||||||
checkable: !ConnectionController.isConnected
|
PageController.goToPage(PageEnum.PageSettingsKillSwitch)
|
||||||
onCheckedChanged: {
|
|
||||||
if (checked !== SettingsController.isKillSwitchEnabled()) {
|
|
||||||
SettingsController.toggleKillSwitch(checked)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
onClicked: {
|
|
||||||
if (!checkable) {
|
|
||||||
PageController.showNotificationMessage(qsTr("Cannot change killSwitch settings during active connection"))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
98
client/ui/qml/Pages2/PageSettingsKillSwitch.qml
Normal file
98
client/ui/qml/Pages2/PageSettingsKillSwitch.qml
Normal file
|
|
@ -0,0 +1,98 @@
|
||||||
|
import QtQuick
|
||||||
|
import QtQuick.Controls
|
||||||
|
import QtQuick.Layouts
|
||||||
|
|
||||||
|
import PageEnum 1.0
|
||||||
|
import Style 1.0
|
||||||
|
|
||||||
|
import "./"
|
||||||
|
import "../Controls2"
|
||||||
|
import "../Config"
|
||||||
|
|
||||||
|
PageType {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
BackButtonType {
|
||||||
|
id: backButton
|
||||||
|
anchors.top: parent.top
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.topMargin: 20
|
||||||
|
}
|
||||||
|
|
||||||
|
FlickableType {
|
||||||
|
id: fl
|
||||||
|
anchors.top: backButton.bottom
|
||||||
|
anchors.bottom: parent.bottom
|
||||||
|
contentHeight: content.height
|
||||||
|
|
||||||
|
ColumnLayout {
|
||||||
|
id: content
|
||||||
|
anchors.top: parent.top
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.right: parent.right
|
||||||
|
|
||||||
|
HeaderType {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.leftMargin: 16
|
||||||
|
Layout.rightMargin: 16
|
||||||
|
|
||||||
|
headerText: qsTr("Kill Switch")
|
||||||
|
descriptionText: qsTr("Enable to ensure network traffic goes through a secure VPN tunnel, preventing accidental exposure of your IP and DNS queries if the connection drops")
|
||||||
|
|
||||||
|
showSwitcher: true
|
||||||
|
switcher {
|
||||||
|
checked: SettingsController.isKillSwitchEnabled
|
||||||
|
enabled: !ConnectionController.isConnected
|
||||||
|
}
|
||||||
|
switcherFunction: function(checked) {
|
||||||
|
if (!ConnectionController.isConnected) {
|
||||||
|
SettingsController.isKillSwitchEnabled = checked
|
||||||
|
} else {
|
||||||
|
PageController.showNotificationMessage(qsTr("Cannot change killSwitch settings during active connection"))
|
||||||
|
switcher.checked = SettingsController.isKillSwitchEnabled
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
VerticalRadioButton {
|
||||||
|
id: softKillSwitch
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.topMargin: 32
|
||||||
|
Layout.leftMargin: 16
|
||||||
|
Layout.rightMargin: 16
|
||||||
|
|
||||||
|
enabled: SettingsController.isKillSwitchEnabled && !ConnectionController.isConnected
|
||||||
|
checked: !SettingsController.strictKillSwitchEnabled
|
||||||
|
|
||||||
|
text: qsTr("Soft Kill Switch")
|
||||||
|
descriptionText: qsTr("Internet connection is blocked if VPN connection drops accidentally")
|
||||||
|
|
||||||
|
onClicked: {
|
||||||
|
SettingsController.strictKillSwitchEnabled = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DividerType {}
|
||||||
|
|
||||||
|
VerticalRadioButton {
|
||||||
|
id: strictKillSwitch
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.leftMargin: 16
|
||||||
|
Layout.rightMargin: 16
|
||||||
|
|
||||||
|
enabled: SettingsController.isKillSwitchEnabled && !ConnectionController.isConnected
|
||||||
|
checked: SettingsController.strictKillSwitchEnabled
|
||||||
|
|
||||||
|
text: qsTr("Strict Kill Switch")
|
||||||
|
descriptionText: qsTr("Internet connection is blocked even if VPN was turned off manually or not started")
|
||||||
|
|
||||||
|
onClicked: {
|
||||||
|
SettingsController.strictKillSwitchEnabled = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DividerType {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue