2020-05-21 21:04:21 +00:00
|
|
|
mod consul;
|
2020-05-22 09:34:12 +00:00
|
|
|
mod consul_actor;
|
2020-02-12 17:33:10 +00:00
|
|
|
|
2020-05-09 14:50:38 +00:00
|
|
|
//use std::net::SocketAddrV4;
|
|
|
|
//use std::collections::HashMap;
|
|
|
|
//use igd::PortMappingProtocol;
|
|
|
|
use log::*;
|
2020-05-21 21:04:21 +00:00
|
|
|
use consul::*;
|
2020-05-09 14:50:38 +00:00
|
|
|
|
2020-02-12 17:33:10 +00:00
|
|
|
#[tokio::main]
|
|
|
|
async fn main() {
|
2020-05-09 13:33:02 +00:00
|
|
|
pretty_env_logger::init();
|
2020-05-09 14:50:38 +00:00
|
|
|
info!("Starting Diplonat");
|
2020-05-21 21:04:21 +00:00
|
|
|
/*
|
2020-05-09 14:50:38 +00:00
|
|
|
let diplo = Diplonat::new().await.expect("Setup failed");
|
2020-05-21 13:22:45 +00:00
|
|
|
diplo.listen().await.expect("A runtime error occured");
|
2020-05-21 21:04:21 +00:00
|
|
|
*/
|
2020-05-22 08:33:09 +00:00
|
|
|
let mut c = Consul::new("http://127.0.0.1:8500");
|
|
|
|
let cn = c.watch_node("lheureduthe").await.expect("Failed to fetch API");
|
2020-05-21 21:04:21 +00:00
|
|
|
println!("{:#?}", cn);
|
2020-05-22 08:33:09 +00:00
|
|
|
let cn2 = c.watch_node("lheureduthe").await.expect("Failed to fetch API");
|
|
|
|
println!("{:#?}", cn2);
|
2020-02-12 18:14:02 +00:00
|
|
|
|
2020-05-21 21:04:21 +00:00
|
|
|
/*
|
2020-02-12 17:33:10 +00:00
|
|
|
let gateway = match search_gateway(Default::default()).await {
|
|
|
|
Ok(g) => g,
|
|
|
|
Err(err) => return println!("Faild to find IGD: {}", err),
|
|
|
|
};
|
|
|
|
|
2020-02-12 23:17:23 +00:00
|
|
|
let service = format!("{}:{}", config.private_ip, 1234);
|
|
|
|
let service: SocketAddrV4 = service.parse().expect("Invalid socket address");
|
|
|
|
match gateway.add_port(PortMappingProtocol::TCP, 1234, service, config.expiration_time, "diplonat").await {
|
2020-02-12 18:14:02 +00:00
|
|
|
Ok(_) => (),
|
|
|
|
Err(e) => return println!("Unable to insert port 1234: {}", e),
|
2020-02-12 17:33:10 +00:00
|
|
|
};
|
2020-05-09 13:53:22 +00:00
|
|
|
*/
|
2020-02-12 17:33:10 +00:00
|
|
|
}
|