From 154546a7b4eb36eb1e78fb814c5fe21c6030c2ee Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Sat, 9 May 2020 16:27:54 +0200 Subject: Split logic in multiple files! --- src/diplonat.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/diplonat.rs') diff --git a/src/diplonat.rs b/src/diplonat.rs index 38b2f8a..c209da5 100644 --- a/src/diplonat.rs +++ b/src/diplonat.rs @@ -1,18 +1,19 @@ -use igd::Gateway; use anyhow::{Result, Context}; - +use log::*; use crate::*; pub struct DiplonatContext { pub config: config::DiplonatConfig, - //pub gateway: igd::Gateway + pub gateway: igd::aio::Gateway } -pub fn setup() -> Result { - return Ok(DiplonatContext { +pub async fn setup() -> Result { + let ctx = DiplonatContext { config: config::load_env().context("Unable to read configuration from environment")?, - //gateway: search_gateway(Default::default()).await - }); + gateway: gw::get_gateway().await? + }; + + return Ok(ctx); } pub fn listen() -> bool { -- cgit v1.2.3