"My Internet IP" is a small rust crate for retrieving the public IP of the device this code is executed on.
````rust extern crate myinternetip;
fn main() { let ip: ::std::net::IpAddr = match myinternetip::get() { Ok(ip) => ip, Err(e) => panic!("Could not get IP: {}", e) };
// Do something with the IP, e.g. print it
} ````
Note: The call to my_internet_ip::get()
blocks until the public IP
was retrieved or an error occurred.
toml
my_internet_ip = "0.0.1"
This crate uses the curl crate to access http://www.myip.ch and parse the result.
MIT