aboutsummaryrefslogblamecommitdiff
path: root/src/main.rs
blob: a4c4e21524a95ccfb45503d9394a1e5d9fd97944 (plain) (tree)
1
2
3
4
5
6
7
8
9
                           


                                
 
                             

                             
             
           


                 

                              

                                                        

                                                                                           
              


                                            
                            
 



                                                                  
                                  
 


                                                                                                               

                                                                       
      
      
 
use std::net::SocketAddrV4;
//use std::collections::HashMap;

use log::*;

use igd::aio::search_gateway;
use igd::PortMappingProtocol;

mod diplonat;
mod config;

#[tokio::main]
async fn main() {
    pretty_env_logger::init();

    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
        .unwrap();
        //.json::<HashMap<String, String>>()
        //.await.unwrap();
    println!("{:#?}", resp);

    let gateway = match search_gateway(Default::default()).await {
        Ok(g) => g,
        Err(err) => return println!("Faild to find IGD: {}", err),
    };
    info!("Gateway: {}", gateway);

    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),
    };
    */
}