Find the public IP address of a device
Documentation hosted on docs.rs.
toml
public-ip = "0.1.0"
```rust use asyncstd::task; use publicip::{dns, http, BoxToResolver, ToResolver};
fn main() { // List of resolvers to try and get an IP address from let resolver = vec![ BoxToResolver::new(dns::OPENDNSRESOLVER), BoxToResolver::new(http::HTTPIPIFYORGRESOLVER), ] .toresolver(); // Attempt to get an IP address and print it if let Some(ip) = task::blockon(publicip::resolveaddress(resolver)) { println!("public ip address: {:?}", ip); } else { println!("couldn't get an IP address"); } } ```