fix: 代理探测只看学习站,手填地址只允许公网

This commit is contained in:
2026-11-16 09:29:45 +08:00
parent 89d9452967
commit 990b80c017
7 changed files with 152 additions and 42 deletions
+12 -5
View File
@@ -53,10 +53,7 @@ def source_title(name: str) -> str:
def is_china(country: str | None) -> bool:
text = (country or "").strip()
if not text:
return False
lower = text.lower()
return lower in CHINA or "中国" in text
return text == "中国" or text.lower() in {"cn", "chn", "china"}
def collect_all() -> list[ProxyCandidate]:
@@ -83,6 +80,10 @@ def _normalize_scheme(value: object) -> str:
kind = str(value or "").strip().lower()
if kind == "socks":
kind = "socks5"
if kind == "socks5h":
kind = "socks5"
if kind == "https":
kind = "http"
return kind if kind in SCHEMES else ""
@@ -90,6 +91,12 @@ def _normalize_host(value: object) -> str:
host = str(value or "").strip()
if not host or "://" in host or any(ch.isspace() for ch in host):
return ""
from euniv.proxy import ProxyError, assert_public_host
try:
assert_public_host(host)
except ProxyError:
return ""
return host[:255]
@@ -205,7 +212,7 @@ class ProxyHubCollector(Collector):
"Mcp-Method": "tools/call",
"Mcp-Name": "list_proxies",
}
with httpx.Client(timeout=20, follow_redirects=True) as client:
with httpx.Client(timeout=20, follow_redirects=True, trust_env=False) as client:
response = client.post(self.url, headers=headers, json=body)
response.raise_for_status()
return parse_proxyhub_result(_read_mcp(response))