geo_lookup

Functionin geofastly 0.13.1View source
fn geo_lookup(ip: IpAddr) -> Option<Geo>

Look up the geographic data associated with a particular IP address.

Returns None if no geographic data is available, such as when the IP address is reserved for private use.

Examples

To get geographic information for the downstream client:

let client_ip = fastly::Request::from_client().get_client_ip_addr().unwrap();
if let Some(geo) = fastly::geo::geo_lookup(client_ip) {
if let fastly::geo::ConnType::Satellite = geo.conn_type() {
println!("receiving a request from outer space 🛸");
}
}

Parameters

ip: std::net::IpAddr

Returns