blob: 9062dd7c9c363ffec2f78597ebdecf8155b12bc9 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
use anyhow::{Result, Context};
use tokio::try_join;
use crate::*;
pub struct Diplonat {
pub config: config::DiplonatConfig,
pub gateway: igd::aio::Gateway
}
impl Diplonat {
pub async fn new() -> Result<Self> {
let ctx = Self {
config: config::load_env().context("Unable to read configuration from environment")?,
gateway: gw::get_gateway().await?
};
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(());
}
}
|