From d6948591a15773a0d157b487c3125f58fb373b92 Mon Sep 17 00:00:00 2001 From: kyx236 Date: Fri, 13 Feb 2026 04:49:30 +0800 Subject: [PATCH] feat: add proxy pool management module --- core/proxy_pool.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/core/proxy_pool.py b/core/proxy_pool.py index aa2f6f9..289fa13 100644 --- a/core/proxy_pool.py +++ b/core/proxy_pool.py @@ -62,6 +62,15 @@ def _parse_line(line: str) -> Proxy | None: if not line or line.startswith("#"): return None + # 优先检查完整 URL 格式(必须在 colon-split 之前,否则会被错误匹配) + if line.startswith(("http://", "https://", "socks5://")): + try: + from urllib.parse import urlparse + parsed = urlparse(line) + return Proxy(raw=line, url=line, host=parsed.hostname or "?", port=str(parsed.port or "?")) + except Exception: + return None + parts = line.split(":") if len(parts) == 4: host, port, user, passwd = parts @@ -71,14 +80,6 @@ def _parse_line(line: str) -> Proxy | None: host, port = parts url = f"http://{host}:{port}" return Proxy(raw=line, url=url, host=host, port=port) - elif line.startswith(("http://", "https://", "socks5://")): - # 从完整 URL 提取 host:port - try: - from urllib.parse import urlparse - parsed = urlparse(line) - return Proxy(raw=line, url=line, host=parsed.hostname or "?", port=str(parsed.port or "?")) - except Exception: - return None return None