diff options
author | Quentin Dufour <quentin@deuxfleurs.fr> | 2020-05-21 22:25:33 +0200 |
---|---|---|
committer | Quentin Dufour <quentin@deuxfleurs.fr> | 2020-05-21 22:25:33 +0200 |
commit | 8c43611eb5bbaeb42f19da8d8ed521df208bfada (patch) | |
tree | c207e950744f451424e139e97aaf852c2d8ff949 /src/igd_adapter.rs | |
parent | 4da459ce8ba49f98084a8ce32f600470ff883ec5 (diff) | |
download | diplonat-8c43611eb5bbaeb42f19da8d8ed521df208bfada.tar.gz diplonat-8c43611eb5bbaeb42f19da8d8ed521df208bfada.zip |
Broken Diplonat
Diffstat (limited to 'src/igd_adapter.rs')
-rw-r--r-- | src/igd_adapter.rs | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/src/igd_adapter.rs b/src/igd_adapter.rs index 3803d5f..6624ab3 100644 --- a/src/igd_adapter.rs +++ b/src/igd_adapter.rs @@ -1,11 +1,30 @@ -use crate::*; -use anyhow::Result; +use igd::aio::*; +use log::*; +use tokio::sync::broadcast; +use anyhow::{Result, Context}; +use std::cell::Cell; -pub struct IgdAdapter {} -impl adapter::Adapter for IgdAdapter { - fn new(&self, parent: &diplonat::Diplonat) -> Result<()> { - return Ok(()); +use crate::diplonat::*; +use crate::node_state::*; + +pub struct IgdAdapter<'a> { + state: &'a Cell<NodeState>, + gateway: Gateway, +} +impl<'a> IgdAdapter<'a> { + pub async fn new(ns: &'a Cell<NodeState>, send: &broadcast::Sender<()>) -> Result<IgdAdapter<'a>> { + let gw = search_gateway(Default::default()) + .await + .context("Failed to find gateway")?; + info!("Gateway: {}", gw); + + let ctx = Self { + state: ns, + gateway: gw + }; + return Ok(ctx); } + fn run(&self) -> Result<()> { return Ok(()); } |