aboutsummaryrefslogtreecommitdiff
path: root/src/diplonat.rs
diff options
context:
space:
mode:
authorQuentin <quentin@dufour.io>2021-08-19 08:32:53 +0200
committerQuentin <quentin@dufour.io>2021-08-19 08:32:53 +0200
commitfa25c54e47decf9f323ba0c614f4d9de106626d5 (patch)
tree2f4524b06b95d8522166732feff59e7246fa86e1 /src/diplonat.rs
parent8b57fb2680673c4ee5a425b262e190fcef724a25 (diff)
parent0f114f21344ddb59f50fed68540c54c41300cf51 (diff)
downloaddiplonat-fa25c54e47decf9f323ba0c614f4d9de106626d5.tar.gz
diplonat-fa25c54e47decf9f323ba0c614f4d9de106626d5.zip
Merge pull request 'Environment parsing done with Serde Envy' (#5) from adrien/diplonat:feature/config-handling into main
Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/diplonat/pulls/5
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,