5 releases

0.2.2 Jan 7, 2022
0.2.1 Jun 15, 2021
0.2.0 Feb 24, 2021
0.1.1 Aug 25, 2020
0.1.0 Jan 19, 2020

#1147 in Network programming

Download history 1313/week @ 2024-12-25 1521/week @ 2025-01-01 2686/week @ 2025-01-08 3590/week @ 2025-01-15 2050/week @ 2025-01-22 2524/week @ 2025-01-29 3316/week @ 2025-02-05 3453/week @ 2025-02-12 2327/week @ 2025-02-19 2280/week @ 2025-02-26 2565/week @ 2025-03-05 2873/week @ 2025-03-12 2046/week @ 2025-03-19 4140/week @ 2025-03-26 2700/week @ 2025-04-02 2613/week @ 2025-04-09

11,931 downloads per month
Used in 24 crates (22 directly)

MIT license

35KB
733 lines

Crate for resolving a devices' own public IP address.

#[tokio::main]
async fn main() {
    // Attempt to get an IP address and print it.
    if let Some(ip) = public_ip::addr().await {
        println!("public ip address: {:?}", ip);
    } else {
        println!("couldn't get an IP address");
    }
}

Build Status Crate Docs

rust-public-ip

Find the public IP address of a device
Documentation hosted on docs.rs.

public-ip = "0.2"

Example usage

#[tokio::main]
async fn main() {
    // Attempt to get an IP address and print it.
    if let Some(ip) = public_ip::addr().await {
        println!("public ip address: {:?}", ip);
    } else {
        println!("couldn't get an IP address");
    }
}

Dependencies

~1–12MB
~128K SLoC