systemprompt_analytics/services/
detection.rs1pub const SPAM_REFERRER_PATTERNS: &[&str] = &[
2 "tyingshoelaces",
3 "buttons-for-website",
4 "darodar",
5 "best-seo-solution",
6 "free-social-buttons",
7 "get-free-traffic-now",
8];
9
10pub const DATACENTER_IP_PREFIXES: &[&str] = &[
11 "47.79.",
12 "47.82.",
13 "14.22.49.",
14 "47.88.",
15 "47.89.",
16 "47.90.",
17 "47.91.",
18 "47.74.",
19 "47.75.",
20 "47.76.",
21 "119.29.",
22 "129.28.",
23 "49.51.",
24 "119.3.",
25 "114.116.",
26 "122.112.",
27];
28
29pub const HIGH_RISK_COUNTRIES: &[&str] = &[
30 "BR", "VN", "AR", "IQ", "BD", "PK", "RU", "VE", "TH", "UA", "ID", "MY", "PH", "NG", "KE", "EG",
31 "MA", "DZ", "TN", "LY", "SY", "IR", "AF", "MM", "KH", "LA", "NP", "LK", "KZ", "UZ", "AZ", "GE",
32 "CN", "SG",
33];
34
35pub fn is_datacenter_ip(ip: &str) -> bool {
36 DATACENTER_IP_PREFIXES
37 .iter()
38 .any(|prefix| ip.starts_with(prefix))
39}
40
41pub fn is_high_risk_country(country: &str) -> bool {
42 HIGH_RISK_COUNTRIES.contains(&country)
43}
44
45pub fn is_spam_referrer(url: &str) -> bool {
46 let url_lower = url.to_lowercase();
47 SPAM_REFERRER_PATTERNS
48 .iter()
49 .any(|pattern| url_lower.contains(pattern))
50}