refactor(backend): optimize database safety, validator performance, and scheduler concurrency
- Fix SQL injection risks in proxy_repo and task_repo - Atomic acquire_pending with UPDATE ... RETURNING - Reuse aiohttp ClientSession in ValidatorService - Replace polling with asyncio.Event in SchedulerService - Optimize ValidationQueue.drain with asyncio.Condition - Concurrent plugin crawling with asyncio.gather - Unify ProxyRaw model import path - Fix test baseline and remove tracked __pycache__ files
This commit is contained in:
@@ -6,19 +6,20 @@ from app.core.log import logger
|
||||
|
||||
|
||||
class ProxyScrapePlugin(BaseHTTPPlugin):
|
||||
default_config = {"max_pages": 5}
|
||||
"""
|
||||
从 ProxyScrape 公开 API 获取代理。
|
||||
覆盖 http/https/socks4/socks5 全协议,专门用于测试插件系统的可扩展性。
|
||||
从 ProxyScrape 公开 API 获取代理库
|
||||
覆盖 http/https/socks4/socks5 全协议,专门用于测试插件系统的可扩展性
|
||||
"""
|
||||
|
||||
name = "proxyscrape"
|
||||
display_name = "ProxyScrape测试源"
|
||||
display_name = "ProxyScrape测试站"
|
||||
description = "从 ProxyScrape API 获取各类型代理(HTTP/HTTPS/SOCKS4/SOCKS5),用于测试架构扩展"
|
||||
enabled = True
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
# 使用多个公开 GitHub 代理列表作为源,稳定性较高
|
||||
# 使用多个公开 GitHub 代理列表作为源,稳定性较差
|
||||
self.urls = [
|
||||
("http", "https://raw.githubusercontent.com/monosans/proxy-list/main/proxies/http.txt"),
|
||||
("https", "https://raw.githubusercontent.com/monosans/proxy-list/main/proxies/https.txt"),
|
||||
@@ -71,5 +72,5 @@ class ProxyScrapePlugin(BaseHTTPPlugin):
|
||||
ip = f"{random.randint(1, 223)}.{random.randint(0, 255)}.{random.randint(0, 255)}.{random.randint(1, 254)}"
|
||||
port = random.randint(1024, 65535)
|
||||
test_proxies.append(ProxyRaw(ip, port, protocol))
|
||||
logger.info(f"生成 {len(test_proxies)} 个测试代理: HTTP/HTTPS/SOCKS4/SOCKS5 各 3 个")
|
||||
logger.info(f"生成 {len(test_proxies)} 个测试代理 HTTP/HTTPS/SOCKS4/SOCKS5 各 3 个")
|
||||
return test_proxies
|
||||
|
||||
Reference in New Issue
Block a user