aboutsummaryrefslogtreecommitdiff
path: root/src/diplonat.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/diplonat.rs')
-rw-r--r--src/diplonat.rs44
1 files changed, 15 insertions, 29 deletions
diff --git a/src/diplonat.rs b/src/diplonat.rs
index 9062dd7..a53a19e 100644
--- a/src/diplonat.rs
+++ b/src/diplonat.rs
@@ -1,45 +1,31 @@
use anyhow::{Result, Context};
-use tokio::try_join;
+use tokio::sync::broadcast;
+use futures::future::try_join_all;
use crate::*;
-pub struct Diplonat {
+pub struct Diplonat<'a> {
pub config: config::DiplonatConfig,
- pub gateway: igd::aio::Gateway
+ pub gateway: igd::aio::Gateway,
+ pub notif: broadcast::Sender<()>,
+ pub public_ports: &'a[u16],
+ adapters: &'a[&'a dyn adapter::Adapter]
}
-impl Diplonat {
- pub async fn new() -> Result<Self> {
- let ctx = Self {
+impl<'a> Diplonat<'a> {
+ pub async fn new() -> Result<Diplonat<'a>> {
+ let (tx, _) = broadcast::channel(1);
+ let ctx = Diplonat {
config: config::load_env().context("Unable to read configuration from environment")?,
- gateway: gw::get_gateway().await?
+ gateway: gw::get_gateway().await?,
+ notif: tx,
+ public_ports: &[110, 111, 112],
+ adapters: &[]
};
return Ok(ctx);
}
- // Action sinks
- pub async fn consul_catalog(&self) -> Result<()> {
- info!("Consul catalog loop started");
- return Ok(());
- }
- pub async fn control_loop(&self) -> Result<()> {
- info!("Control loop started");
- return Ok(());
- }
-
- // Action taps
- pub async fn igd(&self) -> Result<()> {
- info!("IGD loop started");
- return Ok(());
- }
- // @TODO: implement netfilter, dns
-
pub async fn listen(&self) -> Result<()> {
- try_join!(
- self.consul_catalog(),
- self.control_loop(),
- self.igd()
- )?;
return Ok(());
}
}