From 6015d85b7331306dcd4f989b682442f064df9553 Mon Sep 17 00:00:00 2001 From: adrien Date: Wed, 22 Sep 2021 17:02:25 +0200 Subject: [PATCH] WIP: looks better, but the Diplonat new function is still full of shit - I'll investigate --- src/diplonat.rs | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/diplonat.rs b/src/diplonat.rs index d98b6ed..884e8ec 100644 --- a/src/diplonat.rs +++ b/src/diplonat.rs @@ -2,14 +2,16 @@ use std::pin::Pin; use anyhow::{anyhow, Result}; use futures::future::{try_join_all, Future}; -use tokio::try_join; +// use tokio::try_join; + +type ActorTask = Pin>>>; use crate::{ config::ConfigOpts, consul_actor::ConsulActor, fw_actor::FirewallActor, igd_actor::IgdActor, }; pub struct Diplonat { - actors: Vec>>>>, + actors: Vec, } impl Diplonat { @@ -17,14 +19,19 @@ impl Diplonat { let config = ConfigOpts::from_env()?; println!("{:#?}", config); - let consul_actor = ConsulActor::new(config.consul); - let mut actors = vec![Box::pin(consul_actor.listen())]; + let mut consul_actor = ConsulActor::new(config.consul); + let consul_rx = consul_actor.rx_open_ports.clone(); + let actor_task: ActorTask = Box::pin(consul_actor.listen()); - if let Some(actor) = FirewallActor::new(config.firewall, &consul_actor.rx_open_ports)? { - actors.push(Box::pin(actor.listen())); + let mut actors = vec![actor_task]; + + if let Some(mut actor) = FirewallActor::new(config.firewall, &consul_rx)? { + let actor_task: ActorTask = Box::pin(actor.listen()); + actors.push(actor_task); } - if let Some(actor) = IgdActor::new(config.igd, &consul_actor.rx_open_ports).await? { - actors.push(Box::pin(actor.listen())); + if let Some(mut actor) = IgdActor::new(config.igd, &consul_rx).await? { + let actor_task: ActorTask = Box::pin(actor.listen()); + actors.push(actor_task); } if actors.len() == 1 {