1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//! Geographic analysis and impossible travel detection.
//!
//! This module provides geographic anomaly detection capabilities,
//! primarily focused on detecting account takeover attempts through
//! impossible travel patterns.
//!
//! # Overview
//!
//! When a user logs in from two locations in rapid succession, the system
//! calculates whether the required travel speed is physically possible.
//! Commercial jets cruise at ~900 km/h, so speeds above 1000 km/h indicate
//! potential credential compromise.
//!
//! # Components
//!
//! - [`haversine`] - Great-circle distance calculation
//! - [`types`] - Geographic types (GeoLocation, LoginEvent, TravelAlert)
//! - [`impossible_travel`] - Core detection logic
//!
//! # Example
//!
//! ```
//! use synapse_pingora::geo::{
//! ImpossibleTravelDetector, TravelConfig, LoginEvent, GeoLocation,
//! };
//!
//! let mut detector = ImpossibleTravelDetector::new(TravelConfig::default());
//!
//! // First login in NYC
//! let nyc = GeoLocation::new("1.2.3.4", 40.7128, -74.0060, "USA", "US");
//! let event1 = LoginEvent::new("user123", 0, nyc);
//! detector.check_login(&event1);
//!
//! // Second login in London 10 minutes later - impossible!
//! let london = GeoLocation::new("5.6.7.8", 51.5074, -0.1278, "UK", "GB");
//! let event2 = LoginEvent::new("user123", 600_000, london); // 10 min
//! if let Some(alert) = detector.check_login(&event2) {
//! println!("Impossible travel detected: {} at {} km/h",
//! alert.user_id, alert.required_speed_kmh);
//! }
//! ```
// Re-export public API
pub use ;
pub use ImpossibleTravelDetector;
pub use ;