diplonat/src/main.rs

42 lines
1.2 KiB
Rust
Raw Normal View History

mod diplonat;
2020-05-21 20:25:33 +00:00
mod node_state;
mod environment_adapter;
2020-05-21 15:51:30 +00:00
mod igd_adapter;
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 20:25:33 +00:00
use node_state::*;
2020-05-09 14:50:38 +00:00
use diplonat::*;
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-09 13:33:02 +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-08 10:46:10 +00:00
let url = format!("http://127.0.0.1:8500/v1/catalog/node/{}", config.consul_node_name);
let resp = reqwest::get(&url)
.await
2020-05-08 08:57:10 +00:00
.unwrap();
//.json::<HashMap<String, String>>()
//.await.unwrap();
println!("{:#?}", resp);
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 {
Ok(_) => (),
Err(e) => return println!("Unable to insert port 1234: {}", e),
2020-02-12 17:33:10 +00:00
};
*/
2020-02-12 17:33:10 +00:00
}