From 3f6196c06675f8785b482ff3d1a30fde200bf7ca Mon Sep 17 00:00:00 2001 From: Elmar Athmer Date: Tue, 29 Aug 2023 22:37:26 +0200 Subject: [PATCH] re-execute mesh-function every 300 seconds --- src/main.rs | 8 ++++---- src/mesh/wgmesh.rs | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index 93969a6..f2ffe23 100644 --- a/src/main.rs +++ b/src/main.rs @@ -50,8 +50,8 @@ async fn main() -> Result<(), Box> { let routing_service = RoutingServiceImpl::new(handle, &interface_name); let wg_mesh = WgMesh::new(peer_repository, routing_service, wireguard_device); - // TODO: loop/re-execute - wg_mesh.execute(&mesh_record).await?; - - Ok(()) + loop { + wg_mesh.execute(&mesh_record).await?; + sleep(Duration::from_secs(300)).await; + } } diff --git a/src/mesh/wgmesh.rs b/src/mesh/wgmesh.rs index caea5cb..d92633a 100644 --- a/src/mesh/wgmesh.rs +++ b/src/mesh/wgmesh.rs @@ -32,7 +32,7 @@ where } } - pub async fn execute(self, mesh_record: &str) -> Result<(), error::WgMesh> { + pub async fn execute(&self, mesh_record: &str) -> Result<(), error::WgMesh> { let interface_pubkey = self.wireguard.get_interface_pubkey()?; // first, get a list of all Peers belonging to the mesh