rp: set allowed-ips as routes

Prepare the rp app for a systemd unit file that sets up wireguard
connections.
This commit is contained in:
Jacek Galowicz
2024-11-14 14:07:50 +00:00
committed by Paul Spooren
parent 06d4e289a5
commit 022cdc4ffa

View File

@@ -313,6 +313,29 @@ pub async fn exchange(options: ExchangeOptions) -> Result<()> {
broker_peer,
peer.endpoint.map(|x| x.to_string()),
)?;
// Configure routes
if let Some(allowed_ips) = peer.allowed_ips {
Command::new("ip")
.arg("route")
.arg("replace")
.arg(allowed_ips.clone())
.arg("dev")
.arg(options.dev.clone().unwrap_or("rosenpass0".to_string()))
.status()
.expect("failed to configure route");
cleanup_handlers
.enqueue(Box::pin(async move {
Command::new("ip")
.arg("route")
.arg("del")
.arg(allowed_ips)
.status()
.expect("failed to remove ip");
Ok(())
}))
.await;
}
}
let out = srv.event_loop();