Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

from dataclasses import dataclass, field
import uuid
from getpass import getuser

import gi # pylint: disable=C0411
gi.require_version("NM", "1.0")
Expand All @@ -37,6 +38,7 @@
class KillSwitchGeneralConfig: # pylint: disable=missing-class-docstring
human_readable_id: str
interface_name: str
permanent: bool


@dataclass
Expand Down Expand Up @@ -86,6 +88,11 @@ def _create_connection_profile(self):
s_con.set_property(NM.SETTING_CONNECTION_UUID, str(uuid.uuid4()))
s_con.set_property(NM.SETTING_CONNECTION_TYPE, NM.SETTING_DUMMY_SETTING_NAME)

# Only permanent kill switch needs to be a system connection;
# weaker kill switches can be user connections to avoid polkit auth.
if not self._general_settings.permanent:
s_con.add_permission(NM.SETTING_USER_SETTING_NAME, getuser(), None)

s_dummy = NM.SettingDummy.new()

s_ipv4 = self._generate_ipv4_settings()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ async def add_full_killswitch_connection(self, permanent: bool):
interface_name = _get_interface_name(permanent)
general_config = KillSwitchGeneralConfig(
human_readable_id=connection_id,
interface_name=interface_name
interface_name=interface_name,
permanent=permanent
)

kill_switch = KillSwitchConnection(
Expand Down Expand Up @@ -174,7 +175,8 @@ async def add_routed_killswitch_connection(self, server_ip: str, permanent: bool

general_config = KillSwitchGeneralConfig(
human_readable_id=_get_connection_id(self._connection_prefix, permanent, routed=True),
interface_name=_get_interface_name(permanent, routed=True)
interface_name=_get_interface_name(permanent, routed=True),
permanent=permanent
)
kill_switch = KillSwitchConnection(
general_config,
Expand Down Expand Up @@ -204,7 +206,8 @@ async def add_ipv6_leak_protection(self):
interface_name = _get_interface_name(permanent=False, ipv6=True)
general_config = KillSwitchGeneralConfig(
human_readable_id=connection_id,
interface_name=interface_name
interface_name=interface_name,
permanent=False
)

kill_switch = KillSwitchConnection(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

from dataclasses import dataclass, field
import uuid
from getpass import getuser

import gi
gi.require_version("NM", "1.0")
Expand All @@ -37,6 +38,7 @@
class KillSwitchGeneralConfig: # pylint: disable=missing-class-docstring
human_readable_id: str
interface_name: str
permanent: bool


@dataclass
Expand Down Expand Up @@ -86,6 +88,11 @@ def _create_connection_profile(self):
s_con.set_property(NM.SETTING_CONNECTION_UUID, str(uuid.uuid4()))
s_con.set_property(NM.SETTING_CONNECTION_TYPE, NM.SETTING_DUMMY_SETTING_NAME)

# Only permanent kill switch needs to be a system connection;
# weaker kill switches can be user connections to avoid polkit auth.
if not self._general_settings.permanent:
s_con.add_permission(NM.SETTING_USER_SETTING_NAME, getuser(), None)

s_dummy = NM.SettingDummy.new()

s_ipv4 = self._generate_ipv4_settings()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ async def add_kill_switch_connection(self, permanent: bool):

general_config = self._config or KillSwitchGeneralConfig(
human_readable_id=_get_connection_id(permanent),
interface_name=_get_interface_name(permanent)
interface_name=_get_interface_name(permanent),
permanent=permanent
)

connection = self.nm_client.get_active_connection(
Expand Down Expand Up @@ -246,7 +247,8 @@ async def add_ipv6_leak_protection(self):
interface_name = _get_interface_name(permanent=False, ipv6=True)
general_config = KillSwitchGeneralConfig(
human_readable_id=connection_id,
interface_name=interface_name
interface_name=interface_name,
permanent=False
)

kill_switch = KillSwitchConnection(
Expand Down