diff --git a/src/config.rs b/src/config.rs index 950f4fe..bbc1b33 100644 --- a/src/config.rs +++ b/src/config.rs @@ -38,7 +38,12 @@ pub fn load_env() -> Result { return Err(format!("Expiration time (currently: {}s) must be twice bigger than refresh time (currently: {}s)", expiration_time, refresh_time)) } - let config = DiplonatConfig { private_ip: private_ip, refresh_time: refresh_time, expiration_time: expiration_time, consul_node_name: consul_node_name }; + let config = DiplonatConfig { + private_ip: private_ip, + refresh_time: refresh_time, + expiration_time: expiration_time, + consul_node_name: consul_node_name + }; info!("Consul node name: {}", config.consul_node_name); info!("Private IP address: {}", config.private_ip); info!("Refresh time: {} seconds", config.refresh_time); diff --git a/src/diplonat.rs b/src/diplonat.rs new file mode 100644 index 0000000..44f6ac5 --- /dev/null +++ b/src/diplonat.rs @@ -0,0 +1,19 @@ +use igd::Gateway; + +use crate::*; + +pub struct DiplonatContext { + pub config: config::DiplonatConfig, + //pub gateway: igd::Gateway +} + +pub fn setup() -> Result { + return Ok(DiplonatContext { + config: config::load_env()?, + //gateway: search_gateway(Default::default()).await + }); +} + +pub fn dloop() -> bool { + return true; +} diff --git a/src/main.rs b/src/main.rs index 4a08ecc..a4c4e21 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,17 +6,15 @@ use log::*; use igd::aio::search_gateway; use igd::PortMappingProtocol; +mod diplonat; mod config; #[tokio::main] async fn main() { pretty_env_logger::init(); - let config = match config::load_env() { - Ok(val) => val, - Err(e) => return println!("unable to build configuration: {}", e), - }; - + let ctx = diplonat::setup().expect("Setup failed:"); +/* let url = format!("http://127.0.0.1:8500/v1/catalog/node/{}", config.consul_node_name); let resp = reqwest::get(&url) .await @@ -37,4 +35,5 @@ async fn main() { Ok(_) => (), Err(e) => return println!("Unable to insert port 1234: {}", e), }; + */ }