aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2020-05-09 15:53:22 +0200
committerQuentin Dufour <quentin@deuxfleurs.fr>2020-05-09 15:53:22 +0200
commita19ae25a7d20d338243e2fef5a1fd45437701c2a (patch)
tree9d40a4c7a5af1726a60371af435cb391b2bb3c06
parent643d6980e5c0f04928edf05219f735495e5589a5 (diff)
downloaddiplonat-a19ae25a7d20d338243e2fef5a1fd45437701c2a.tar.gz
diplonat-a19ae25a7d20d338243e2fef5a1fd45437701c2a.zip
Rewrite with modules, still in progress...
-rw-r--r--src/config.rs7
-rw-r--r--src/diplonat.rs19
-rw-r--r--src/main.rs9
3 files changed, 29 insertions, 6 deletions
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<DiplonatConfig, String> {
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<DiplonatContext, String> {
+ 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),
};
+ */
}