Crates.io | query_external_ip |
lib.rs | query_external_ip |
version | 0.1.1 |
source | src |
created_at | 2021-07-04 12:32:24.317149 |
updated_at | 2021-07-04 16:47:54.537255 |
description | Asynchronous library for querying the system's external IPv4 and IPv6 |
homepage | |
repository | https://github.com/vladvasiliu/query_external_ip.git |
max_upload_size | |
id | 418567 |
size | 8,634 |
Get the external IPv4 and IPv6 of the computer.
use query_external_ip::Consensus;
async fn get_ip() {
match Consensus::get().await {
Ok(c) => println!("{:#?}", c),
Err(err) => println!("{}", err),
}
}
The sources used provide this service for free, so please don't abuse their kindness.
As the external IP doesn't change all that often, I'd recommended waiting at least 10 minutes between queries.
This is an early beta. It only queries IPs from a bunch of HTTP endpoints.
More tests need to be written.
Contributions, in the form of pull requests and issues are welcome.
This is strongly inspired by Dario Meloni's external-ip.
The main reason for building this new crate was to provide both IPv4 and IPv6 addresses.
There's also rust-public-ip which seems to do the same thing.
This program is released under the terms of the BSD 3-Clause license. You may