Browse Source

consul lib does not work for us, switching to reqwest

main
Quentin 1 year ago
parent
commit
fdffe91397
  1. 926
      Cargo.lock
  2. 2
      Cargo.toml
  3. 2
      diplonat_debug
  4. 16
      src/main.rs

926
Cargo.lock
File diff suppressed because it is too large
View File

2
Cargo.toml

@ -7,6 +7,6 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
consul = "0.3.0"
reqwest = { version = "0.10", features = ["json"] }
igd = { version = "0.10.0", features = ["aio"] }
tokio = "0.2.11"

2
diplonat_debug

@ -1,5 +1,7 @@
#!/bin/bash
# http://127.0.0.1:8500/v1/catalog/node/rincevent?index=0
# then look at X-Consul-Index
export DIPLONAT_PRIVATE_IP=10.3.3.37
export DIPLONAT_REFRESH_TIME=60
export DIPLONAT_EXPIRATION_TIME=180

16
src/main.rs

@ -4,8 +4,7 @@ use std::net::SocketAddrV4;
use igd::aio::search_gateway;
use igd::PortMappingProtocol;
use consul::catalog::Catalog;
use consul::{Client, Config};
use std::collections::HashMap;
struct DiplonatConfig {
private_ip: String,
@ -58,13 +57,12 @@ async fn main() {
Err(e) => return println!("unable to build configuration: {}", e),
};
let consul_config = Config::new().unwrap();
let consul_client = Client::new(consul_config);
match consul_client.nodes(None) {
Ok(v) => println!("ok: {:?}", v),
Err(err) => println!("err: {}", err),
};
let resp = reqwest::get("http://127.0.0.1:5000")
.await
.unwrap()
.json::<HashMap<String, String>>()
.await.unwrap();
println!("{:#?}", resp);
let gateway = match search_gateway(Default::default()).await {
Ok(g) => g,

Loading…
Cancel
Save