aboutsummaryrefslogtreecommitdiff
path: root/src/igd_adapter.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/igd_adapter.rs')
-rw-r--r--src/igd_adapter.rs31
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(());
}