#ip-address #ip #public #async #external

public-ip

Find the public IP address of a device

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

#1918 in Network programming

Download history 5140/week @ 2023-11-27 5940/week @ 2023-12-04 5754/week @ 2023-12-11 4912/week @ 2023-12-18 3015/week @ 2023-12-25 4181/week @ 2024-01-01 5080/week @ 2024-01-08 4928/week @ 2024-01-15 5802/week @ 2024-01-22 5917/week @ 2024-01-29 5142/week @ 2024-02-05 5205/week @ 2024-02-12 6219/week @ 2024-02-19 6471/week @ 2024-02-26 6571/week @ 2024-03-04 2337/week @ 2024-03-11

22,008 downloads per month
Used in 20 crates (18 directly)

MIT license

35KB
733 lines

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");
    }
}

lib.rs:

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");
    }
}

Dependencies

~1–14MB
~143K SLoC