Expand description
Library to query IP2Proxy BIN Data files. They contain known proxies, geolocation information, and other meta data for IP address ranges.
https://www.ip2location.com/ is a commercial provider, offering various database files for download.
Supports IPv4 and IPv6.
§Example
use ip2proxy::{Columns, Database, Row};
let db = Database::open("data/IP2PROXY-IP-PROXYTYPE-COUNTRY-REGION-CITY-ISP.SAMPLE.BIN")?;
assert_eq!(db.package_version(), 4);
assert_eq!(db.database_version(), "16.11.17");
if let Some(row) = db.query("1.0.0.1".parse()?, Columns::all())? {
assert_eq!(row.proxy_type, Some(String::from("DCH")));
assert_eq!(row.country_short, Some(String::from("AU")));
assert_eq!(row.country_long, Some(String::from("Australia")));
assert_eq!(row.region, Some(String::from("Queensland")));
assert_eq!(row.city, Some(String::from("Brisbane")));
assert_eq!(row.isp, Some(String::from("Research Prefix for APNIC Labs")));
}
§Cargo features
serde
: Implementserde::Serialize
andserde::Deserialize
forRow
.