aboutsummaryrefslogtreecommitdiff
path: root/src/diplonat.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/diplonat.rs')
-rw-r--r--src/diplonat.rs18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/diplonat.rs b/src/diplonat.rs
index a4cb787..565c567 100644
--- a/src/diplonat.rs
+++ b/src/diplonat.rs
@@ -1,28 +1,34 @@
use anyhow::Result;
-use futures::future::try_join_all;
use log::*;
+use tokio::try_join;
use crate::consul_actor::ConsulActor;
+use crate::igd_actor::IgdActor;
use crate::environment::Environment;
pub struct Diplonat {
- consul: ConsulActor
+ consul: ConsulActor,
+ igd: IgdActor
}
impl Diplonat {
pub async fn new() -> Result<Self> {
let env = Environment::new()?;
+ let ca = ConsulActor::new(&env.consul_url, &env.consul_node_name);
+ let ia = IgdActor::new(&ca.rx_open_ports).await?;
let ctx = Self {
- consul: ConsulActor::new(&env.consul_url, &env.consul_node_name)
+ consul: ca,
+ igd: ia
};
return Ok(ctx);
}
pub async fn listen(&mut self) -> Result<()> {
- try_join_all(vec![
- self.consul.listen()
- ]).await?;
+ try_join!(
+ self.consul.listen(),
+ self.igd.listen()
+ )?;
return Ok(());
}