32 lines
766 B
Rust
32 lines
766 B
Rust
use anyhow::{Result, Context};
|
|
use tokio::sync::broadcast;
|
|
use futures::future::try_join_all;
|
|
use crate::*;
|
|
|
|
pub struct Diplonat<'a> {
|
|
pub config: config::DiplonatConfig,
|
|
pub gateway: igd::aio::Gateway,
|
|
pub notif: broadcast::Sender<()>,
|
|
pub public_ports: &'a[u16],
|
|
adapters: &'a[&'a dyn adapter::Adapter]
|
|
}
|
|
|
|
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?,
|
|
notif: tx,
|
|
public_ports: &[110, 111, 112],
|
|
adapters: &[]
|
|
};
|
|
|
|
return Ok(ctx);
|
|
}
|
|
|
|
pub async fn listen(&self) -> Result<()> {
|
|
return Ok(());
|
|
}
|
|
}
|