Renamed exclusion and inclusion drop-ins to include the network they are for
This commit is contained in:
parent
c0c9daf45d
commit
6279e9e860
@ -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(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user