Created
October 10, 2014 11:05
-
-
Save kstep/9036e9eb002a4fbbfcbf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::io::net; | |
fn get_my_external_ip() -> Option<net::ip::IpAddr> { | |
net::tcp::TcpStream::connect("8.8.8.8", 53).and_then(|ref mut s| s.socket_name()).map(|a| a.ip).ok() | |
} | |
fn main() { | |
println!("My external IP: {}", get_my_external_ip()); | |
} |
Author
kstep
commented
Oct 10, 2014
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment