|
| 1 | +diff --git a/proton/vpn/backend/networkmanager/killswitch/default/killswitch_connection.py b/proton/vpn/backend/networkmanager/killswitch/default/killswitch_connection.py |
| 2 | +index 57ad6fa..49a21aa 100644 |
| 3 | +--- a/proton/vpn/backend/networkmanager/killswitch/default/killswitch_connection.py |
| 4 | ++++ b/proton/vpn/backend/networkmanager/killswitch/default/killswitch_connection.py |
| 5 | +@@ -24,6 +24,7 @@ along with ProtonVPN. If not, see <https://www.gnu.org/licenses/>. |
| 6 | + |
| 7 | + from dataclasses import dataclass, field |
| 8 | + import uuid |
| 9 | ++from getpass import getuser |
| 10 | + |
| 11 | + import gi # pylint: disable=C0411 |
| 12 | + gi.require_version("NM", "1.0") |
| 13 | +@@ -37,6 +38,7 @@ DEFAULT_METRIC = -1 |
| 14 | + class KillSwitchGeneralConfig: # pylint: disable=missing-class-docstring |
| 15 | + human_readable_id: str |
| 16 | + interface_name: str |
| 17 | ++ permanent: bool |
| 18 | + |
| 19 | + |
| 20 | + @dataclass |
| 21 | +@@ -86,6 +88,11 @@ class KillSwitchConnection: # pylint: disable=too-few-public-methods |
| 22 | + s_con.set_property(NM.SETTING_CONNECTION_UUID, str(uuid.uuid4())) |
| 23 | + s_con.set_property(NM.SETTING_CONNECTION_TYPE, NM.SETTING_DUMMY_SETTING_NAME) |
| 24 | + |
| 25 | ++ # Only permanent kill switch needs to be a system connection; |
| 26 | ++ # weaker kill switches can be user connections to avoid polkit auth. |
| 27 | ++ if not self._general_settings.permanent: |
| 28 | ++ s_con.add_permission(NM.SETTING_USER_SETTING_NAME, getuser(), None) |
| 29 | ++ |
| 30 | + s_dummy = NM.SettingDummy.new() |
| 31 | + |
| 32 | + s_ipv4 = self._generate_ipv4_settings() |
| 33 | +diff --git a/proton/vpn/backend/networkmanager/killswitch/default/killswitch_connection_handler.py b/proton/vpn/backend/networkmanager/killswitch/default/killswitch_connection_handler.py |
| 34 | +index 831d962..425adf5 100644 |
| 35 | +--- a/proton/vpn/backend/networkmanager/killswitch/default/killswitch_connection_handler.py |
| 36 | ++++ b/proton/vpn/backend/networkmanager/killswitch/default/killswitch_connection_handler.py |
| 37 | +@@ -144,7 +144,8 @@ class KillSwitchConnectionHandler: |
| 38 | + interface_name = _get_interface_name(permanent) |
| 39 | + general_config = KillSwitchGeneralConfig( |
| 40 | + human_readable_id=connection_id, |
| 41 | +- interface_name=interface_name |
| 42 | ++ interface_name=interface_name, |
| 43 | ++ permanent=permanent |
| 44 | + ) |
| 45 | + |
| 46 | + kill_switch = KillSwitchConnection( |
| 47 | +@@ -174,7 +175,8 @@ class KillSwitchConnectionHandler: |
| 48 | + |
| 49 | + general_config = KillSwitchGeneralConfig( |
| 50 | + human_readable_id=_get_connection_id(self._connection_prefix, permanent, routed=True), |
| 51 | +- interface_name=_get_interface_name(permanent, routed=True) |
| 52 | ++ interface_name=_get_interface_name(permanent, routed=True), |
| 53 | ++ permanent=permanent |
| 54 | + ) |
| 55 | + kill_switch = KillSwitchConnection( |
| 56 | + general_config, |
| 57 | +@@ -204,7 +206,8 @@ class KillSwitchConnectionHandler: |
| 58 | + interface_name = _get_interface_name(permanent=False, ipv6=True) |
| 59 | + general_config = KillSwitchGeneralConfig( |
| 60 | + human_readable_id=connection_id, |
| 61 | +- interface_name=interface_name |
| 62 | ++ interface_name=interface_name, |
| 63 | ++ permanent=False |
| 64 | + ) |
| 65 | + |
| 66 | + kill_switch = KillSwitchConnection( |
| 67 | +diff --git a/proton/vpn/backend/networkmanager/killswitch/wireguard/killswitch_connection.py b/proton/vpn/backend/networkmanager/killswitch/wireguard/killswitch_connection.py |
| 68 | +index 4813fbc..59cf700 100644 |
| 69 | +--- a/proton/vpn/backend/networkmanager/killswitch/wireguard/killswitch_connection.py |
| 70 | ++++ b/proton/vpn/backend/networkmanager/killswitch/wireguard/killswitch_connection.py |
| 71 | +@@ -24,6 +24,7 @@ along with ProtonVPN. If not, see <https://www.gnu.org/licenses/>. |
| 72 | + |
| 73 | + from dataclasses import dataclass, field |
| 74 | + import uuid |
| 75 | ++from getpass import getuser |
| 76 | + |
| 77 | + import gi |
| 78 | + gi.require_version("NM", "1.0") |
| 79 | +@@ -37,6 +38,7 @@ DEFAULT_METRIC = -1 |
| 80 | + class KillSwitchGeneralConfig: # pylint: disable=missing-class-docstring |
| 81 | + human_readable_id: str |
| 82 | + interface_name: str |
| 83 | ++ permanent: bool |
| 84 | + |
| 85 | + |
| 86 | + @dataclass |
| 87 | +@@ -86,6 +88,11 @@ class KillSwitchConnection: # pylint: disable=too-few-public-methods |
| 88 | + s_con.set_property(NM.SETTING_CONNECTION_UUID, str(uuid.uuid4())) |
| 89 | + s_con.set_property(NM.SETTING_CONNECTION_TYPE, NM.SETTING_DUMMY_SETTING_NAME) |
| 90 | + |
| 91 | ++ # Only permanent kill switch needs to be a system connection; |
| 92 | ++ # weaker kill switches can be user connections to avoid polkit auth. |
| 93 | ++ if not self._general_settings.permanent: |
| 94 | ++ s_con.add_permission(NM.SETTING_USER_SETTING_NAME, getuser(), None) |
| 95 | ++ |
| 96 | + s_dummy = NM.SettingDummy.new() |
| 97 | + |
| 98 | + s_ipv4 = self._generate_ipv4_settings() |
| 99 | +diff --git a/proton/vpn/backend/networkmanager/killswitch/wireguard/killswitch_connection_handler.py b/proton/vpn/backend/networkmanager/killswitch/wireguard/killswitch_connection_handler.py |
| 100 | +index 3dd755d..5f72b1b 100644 |
| 101 | +--- a/proton/vpn/backend/networkmanager/killswitch/wireguard/killswitch_connection_handler.py |
| 102 | ++++ b/proton/vpn/backend/networkmanager/killswitch/wireguard/killswitch_connection_handler.py |
| 103 | +@@ -115,7 +115,8 @@ class KillSwitchConnectionHandler: |
| 104 | + |
| 105 | + general_config = self._config or KillSwitchGeneralConfig( |
| 106 | + human_readable_id=_get_connection_id(permanent), |
| 107 | +- interface_name=_get_interface_name(permanent) |
| 108 | ++ interface_name=_get_interface_name(permanent), |
| 109 | ++ permanent=permanent |
| 110 | + ) |
| 111 | + |
| 112 | + connection = self.nm_client.get_active_connection( |
| 113 | +@@ -246,7 +247,8 @@ class KillSwitchConnectionHandler: |
| 114 | + interface_name = _get_interface_name(permanent=False, ipv6=True) |
| 115 | + general_config = KillSwitchGeneralConfig( |
| 116 | + human_readable_id=connection_id, |
| 117 | +- interface_name=interface_name |
| 118 | ++ interface_name=interface_name, |
| 119 | ++ permanent=False |
| 120 | + ) |
| 121 | + |
| 122 | + kill_switch = KillSwitchConnection( |
0 commit comments