aboutsummaryrefslogtreecommitdiff
path: root/src/diplonat.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/diplonat.rs')
-rw-r--r--src/diplonat.rs21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/diplonat.rs b/src/diplonat.rs
index a94a6f8..96bac3b 100644
--- a/src/diplonat.rs
+++ b/src/diplonat.rs
@@ -1,4 +1,5 @@
-use anyhow::Result;
+use anyhow::{Context, Result};
+use futures::future::FutureExt;
use tokio::try_join;
use crate::{
@@ -15,7 +16,7 @@ pub struct Diplonat {
impl Diplonat {
pub async fn new() -> Result<Self> {
- let rt_cfg = ConfigOpts::from_env()?;
+ let rt_cfg = ConfigOpts::from_env().context("Parse configuration")?;
println!("{:#?}", rt_cfg);
let ca = ConsulActor::new(&rt_cfg.consul, &rt_cfg.consul.node_name);
@@ -25,7 +26,8 @@ impl Diplonat {
rt_cfg.firewall.refresh_time,
&ca.rx_open_ports,
)
- .await?;
+ .await
+ .context("Setup fireall actor")?;
let ia = match rt_cfg.igd {
Some(igdc) => Some(
@@ -35,7 +37,8 @@ impl Diplonat {
igdc.expiration_time,
&ca.rx_open_ports,
)
- .await?,
+ .await
+ .context("Setup IGD actor")?,
),
None => None,
};
@@ -56,16 +59,18 @@ impl Diplonat {
let igd_opt = &mut self.igd;
try_join!(
- self.consul.listen(),
+ self.consul.listen().map(|x| x.context("Run consul actor")),
async {
if let Some(igd) = igd_opt {
- igd.listen().await
+ igd.listen().await.context("Run IGD actor")
} else {
Ok(())
}
},
- self.firewall.listen(),
- self.stun.listen(),
+ self.firewall
+ .listen()
+ .map(|x| x.context("Run firewall actor")),
+ self.stun.listen().map(|x| x.context("Run STUN actor")),
)?;
Ok(())