Crates.io | seeip |
lib.rs | seeip |
version | 3.0.1 |
source | src |
created_at | 2022-04-04 11:05:11.294635 |
updated_at | 2024-08-05 18:14:46.816367 |
description | Rust Wrapper for the IP Info https://seeip.org/ API |
homepage | https://github.com/mark-ruddy/seeip |
repository | https://github.com/mark-ruddy/seeip |
max_upload_size | |
id | 561934 |
size | 47,741 |
Rust Wrapper for the IP Info https://seeip.org/ API
See example project using this seeip
library: https://github.com/mark-ruddy/ipfetch
All of the below examples support both IPv4 and IPv6 addresses.
To specifically use either IPv4 or IPv6 use their _v4()
and _v6()
equivalents.
let my_ip = seeip::get_ip().unwrap();
println!("My IP: {}", my_ip);
let my_geo_info = seeip::get_caller_geo().unwrap();
// Fields in GeoInfo can default out to empty values if not available from the API
println!("Country my IP matches: {}", my_geo_info.country);
let geo_info = seeip::get_geo("208.67.222.222").unwrap();
println!("Country matching this IP: {}", geo_info.country);
The tests involve making actual API calls. This means that they can fail if you make an IPv6-only call when your host does not support IPv6:
If you are on a host supporting both IPv4 and IPv6: cargo test --verbose
For a host that only supports IPv4: cargo test --verbose -- --skip v6
For a host that only supports IPv6: cargo test --verbose -- --skip v4