forked from Deuxfleurs/infrastructure
[diplomate] We can get our public IP address!
This commit is contained in:
parent
96c6da392f
commit
94ac5b58a1
3 changed files with 1833 additions and 2 deletions
1817
docker/diplomate/Cargo.lock
generated
1817
docker/diplomate/Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -7,3 +7,6 @@ edition = "2018"
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
consul = "0.3.0"
|
||||||
|
igd = { version = "0.10.0", features = ["aio"] }
|
||||||
|
tokio = "0.2.11"
|
||||||
|
|
|
@ -1,3 +1,14 @@
|
||||||
fn main() {
|
use igd::aio::search_gateway;
|
||||||
println!("Hello, world!");
|
#[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);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue