Skip to content

Commit

Permalink
Connection + NM: Do not set never-default with WireGuard
Browse files Browse the repository at this point in the history
  • Loading branch information
jwijenbergh committed Oct 20, 2023
1 parent c6df736 commit 6076987
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
1 change: 0 additions & 1 deletion eduvpn/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,5 @@ def parse(cls, config_str, _) -> "WireGuardConnection":
def connect(self, manager, default_gateway, dns_search_domains, callback):
manager.start_wireguard_connection(
self.config,
default_gateway,
callback=callback,
)
12 changes: 6 additions & 6 deletions eduvpn/nm.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ def set_connection(
self,
new_connection: "NM.SimpleConnection",
callback: Callable,
default_gateway: bool,
default_gateway: Optional[bool],
dns_search_domains: List[str]=[],
):
new_connection = self.set_setting_ip_config(
Expand All @@ -411,14 +411,15 @@ def set_connection(
self.add_connection(new_connection, callback)

def set_setting_ip_config(
self, con: "NM.SimpleConnection", default_gateway: bool, dns_search_domains: List[str]=[]
self, con: "NM.SimpleConnection", default_gateway: Optional[bool], dns_search_domains: List[str]=[]
) -> "NM.SimpleConnection":
"Set IP config settings like default gateway and search domains."
_logger.debug(f"setting ip config, default gateway: {default_gateway}, dns_search_domains: {dns_search_domains}")
ipv4_setting = con.get_setting_ip4_config()
ipv6_setting = con.get_setting_ip6_config()
ipv4_setting.set_property("never-default", not default_gateway)
ipv6_setting.set_property("never-default", not default_gateway)
if default_gateway is not None:
ipv4_setting.set_property("never-default", not default_gateway)
ipv6_setting.set_property("never-default", not default_gateway)
if dns_search_domains:
ipv4_setting.set_property("dns-search", dns_search_domains)
ipv6_setting.set_property("dns-search", dns_search_domains)
Expand All @@ -444,7 +445,6 @@ def start_openvpn_connection(
def start_wireguard_connection( # noqa: C901
self,
config: ConfigParser,
default_gateway,
*,
callback=None,
) -> None:
Expand Down Expand Up @@ -583,7 +583,7 @@ def start_wireguard_connection( # noqa: C901
profile.add_setting(s_con)
profile.add_setting(w_con)

self.set_connection(profile, callback, default_gateway) # type: ignore
self.set_connection(profile, callback, None) # type: ignore

@run_in_glib_thread
def activate_connection(self, callback: Optional[Callable] = None) -> None:
Expand Down

0 comments on commit 6076987

Please sign in to comment.