[diplomate] We can get our public IP address!

This commit is contained in:
Quentin 2020-02-09 21:23:32 +01:00
parent 96c6da392f
commit 94ac5b58a1
3 changed files with 1833 additions and 2 deletions

File diff suppressed because it is too large Load diff

View file

@ -7,3 +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"
igd = { version = "0.10.0", features = ["aio"] }
tokio = "0.2.11"

View file

@ -1,3 +1,14 @@
fn main() {
println!("Hello, world!");
use igd::aio::search_gateway;
#[tokio::main]
async fn main() {
let gateway = match search_gateway(Default::default()).await {
Ok(g) => g,
Err(err) => return println!("Faild to find IGD: {}", err),
};
let pub_ip = match gateway.get_external_ip().await {
Ok(ip) => ip,
Err(err) => return println!("Failed to get external IP: {}", err),
};
println!("Our public IP is {}", pub_ip);
}