blob: 6624ab3230694dc741e93a812136c06fe8bceef3 (
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
|
use igd::aio::*;
use log::*;
use tokio::sync::broadcast;
use anyhow::{Result, Context};
use std::cell::Cell;
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(());
}
}
|