aboutsummaryrefslogtreecommitdiff
path: root/src/diplonat.rs
diff options
context:
space:
mode:
authorLUXEY Adrien <adrien.luxey@inria.fr>2021-08-16 11:19:16 +0200
committerLUXEY Adrien <adrien.luxey@inria.fr>2021-08-16 11:19:16 +0200
commit644e7079562b3218243c98c89b5bcb47c1d1ab48 (patch)
tree572d8192c8dad6266b82536edbcfb1fba1dc75f3 /src/diplonat.rs
parentae9550ce23bbc85b05669fe5ec4406c8a67417ec (diff)
downloaddiplonat-644e7079562b3218243c98c89b5bcb47c1d1ab48.tar.gz
diplonat-644e7079562b3218243c98c89b5bcb47c1d1ab48.zip
environment.rs successfully replaced with new config/ configuration loader. No API changes, more tests, cleaner code: life is swell.
Diffstat (limited to 'src/diplonat.rs')
-rw-r--r--src/diplonat.rs28
1 files changed, 16 insertions, 12 deletions
diff --git a/src/diplonat.rs b/src/diplonat.rs
index 798b779..7049530 100644
--- a/src/diplonat.rs
+++ b/src/diplonat.rs
@@ -1,31 +1,35 @@
use anyhow::Result;
use tokio::try_join;
+
+use crate::config::ConfigOpts;
use crate::consul_actor::ConsulActor;
-use crate::igd_actor::IgdActor;
-use crate::environment::Environment;
use crate::fw_actor::FirewallActor;
+use crate::igd_actor::IgdActor;
pub struct Diplonat {
consul: ConsulActor,
+ firewall: FirewallActor,
igd: IgdActor,
- firewall: FirewallActor
}
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(
- &env.private_ip,
- env.refresh_time,
- env.expiration_time,
- &ca.rx_open_ports
- ).await?;
+ let rt_cfg = ConfigOpts::from_env()?;
+ println!("{:#?}", rt_cfg);
+
+ let ca = ConsulActor::new(&rt_cfg.consul.url, &rt_cfg.consul.node_name);
let fw = FirewallActor::new(
- env.refresh_time,
+ rt_cfg.firewall.refresh_time,
&ca.rx_open_ports
).await?;
+
+ let ia = IgdActor::new(
+ &rt_cfg.igd.private_ip,
+ rt_cfg.igd.refresh_time,
+ rt_cfg.igd.expiration_time,
+ &ca.rx_open_ports
+ ).await?;
let ctx = Self {
consul: ca,