From 6279e9e860db3ff131b5ba23f9b3ba3d87f6990b Mon Sep 17 00:00:00 2001 From: Ezri Brimhall Date: Tue, 3 Feb 2026 16:20:02 -0700 Subject: [PATCH] Renamed exclusion and inclusion drop-ins to include the network they are for --- src/vpn_manager_globalprotect/vpnc.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/vpn_manager_globalprotect/vpnc.py b/src/vpn_manager_globalprotect/vpnc.py index 766ff62..82866e4 100644 --- a/src/vpn_manager_globalprotect/vpnc.py +++ b/src/vpn_manager_globalprotect/vpnc.py @@ -139,7 +139,9 @@ class Config: # Refuse to create a policy rule that would block the uplink. # this is probably a global route, which we will already have. return - with (dir / f"inclusion-{route_id}.conf").open("w") as stream: + with (dir / f"inclusion-{str(net).replace('/', '_')}.conf").open( + "w" + ) as stream: stream.writelines( [ "[RoutingPolicyRule]\n", @@ -166,7 +168,7 @@ class Config: if not self.vpnd_enforce_split_tunnel: return route_id = self.route_id - with (dir / f"exclusion-{route_id}.conf").open("w") as stream: + with (dir / f"exclusion-{str(net).replace('/', '_')}.conf").open("w") as stream: stream.writelines( [ "[RoutingPolicyRule]\n", @@ -241,6 +243,18 @@ class Config: ) stream.close() + def destroy_config(self, path: Path): + """Destroy the systemd-networkd config.""" + if path.is_file(): + path.unlink() + dropins = path.with_suffix(".network.d") + if dropins.is_dir(): + for file in dropins.iterdir(): + file.unlink() + dropins.rmdir() + elif dropins.exists(): + dropins.unlink() + async def main(): """Main loop.""" @@ -281,6 +295,8 @@ async def configure_with_networkd(): os.dup2(fd, 6, inheritable=True) os.close(fd) return + elif config.reason == Reason.DISCONNECT: + config.destroy_config() # always reload networkd state unless it's the config. bus = bus_var.get() intro = await bus.introspect(