Commit Graph

43 Commits

Author SHA1 Message Date
祀梦
02cd37db71 feat(dashboard): optimize dashboard layout and add new charts 2026-04-05 21:04:49 +08:00
祀梦
7d5eaa438a feat: external plugin loading, score threshold, expiry cleanup and more improvements
Made-with: Cursor
2026-04-05 18:53:33 +08:00
祀梦
7bc6d4e4de feat: JSON 配置、质量分与仪表盘,及设置与爬取流程
- 后端改为 config/app.json;pytest 使用 config/app.test.json 与 set_config_file,不再依赖环境变量;移除 pydantic-settings。

- 前端 API/WebSocket 由 config/webui.json 经 Vite define 注入。

- 代理分数按延迟与随机取用次数计算,新增 use_count 与 proxy_scoring;保存设置时同步调度器启停。

- 仪表盘双饼图(可用/待验证协议);设置页去掉调度器启停按钮并移动立即验证;爬取全部结束后自动提交全量验证。

- 删除 script/settings_maintain.py(此前已标记删除)。

Made-with: Cursor
2026-04-05 16:08:32 +08:00
祀梦
07248ff4ee feat(crawl): browser-like headers, HTTP/2, curl_cffi TLS fingerprint fallback
- get_headers(url): Referer, Sec-Fetch-*, sec-ch-ua, API vs HTML Accept
- httpx AsyncClient/ sync Client with optional HTTP/2 (h2 extra)
- On 403/429/503/520-523/525/567 or request errors, retry via curl_cffi chrome124 impersonate
- POST: Origin, Referer, Content-Type for form posts
- kuaidaili/ip3366: forward get_headers(url=...)

Made-with: Cursor
2026-04-05 14:40:36 +08:00
祀梦
ce667dba13 test: skip network/live crawl by default; fix settings e2e key
- pytest_collection_modifyitems: skip @pytest.mark.network unless PROXYPOOL_RUN_NETWORK_TESTS=1
- Document opt-in in tests/README.md
- e2e: replace removed crawl_timeout with validation_timeout

Made-with: Cursor
2026-04-05 14:33:29 +08:00
祀梦
e582067316 fix(plugins): fpw parsers for JSON API, mirrors, and looser HTML
- fpw_proxy_list_download: parse JSON list/proxies bodies; jsDelivr monosans tier; crawl timeout 300s
- fpw_socks_ssl: try parse_html_table before regex
- fpw_hidemy: loose row scan when fixed columns fail
- fpw_proxynova: plain IP/port row fallback
- fpw_spys_one: HTTPS endpoints; crawl timeout 180s
- fpw_gatherproxy: HTTPS + extra JSON key patterns
- fpw_checkerproxy: lower min HTML length for parse
- fpw_premproxy: ip:port regex fallback when few table rows

Made-with: Cursor
2026-04-05 14:16:03 +08:00
祀梦
a26ae50051 refactor(crawl): parallel plugins via JobExecutor; per-plugin throttle
- Remove global crawl_slot gate; all CrawlJobs share only executor semaphore
- max_concurrent_jobs = max(24, n_plugins+8) for crawl-all + aggregator headroom
- BaseHTTPPlugin max_concurrency 3->2; fpw multi-URL plugins 4->2
- fetch_all: short random delay before each request to ease single-host pressure

Made-with: Cursor
2026-04-05 14:08:26 +08:00
祀梦
957cee3100 fix(crawl): throttle concurrent CrawlJobs and relax fpw/proxyscrape HTTP
- CrawlJob waits on crawl_slot before JobExecutor semaphore so crawl-all does not fill slots while queued
- BaseHTTPPlugin: longer connect budget for slow international links
- proxyscrape: jsDelivr mirror + longer GitHub/API phases
- fpw_*: higher timeouts/retries; lower internal concurrency on heavy multi-URL plugins

Made-with: Cursor
2026-04-05 13:48:41 +08:00
祀梦
2c98abaf91 fix(sqlite): avoid validation database locked under high concurrency
- Release DB connection during validator.validate(); serialize writes with asyncio.Lock
- Add busy_timeout and longer connect timeout on aiosqlite connections
- WAL writes no longer contend across 120 parallel workers holding long-lived connections

Made-with: Cursor
2026-04-05 13:43:18 +08:00
祀梦
46d84a0cdc chore: remove scripts/ dir; move settings maintenance to script/settings_maintain.py
Avoids path autocomplete clash with script/start.bat under script/

Made-with: Cursor
2026-04-05 13:41:38 +08:00
祀梦
0131c8b408 feat: fpw plugins, validation/crawl perf, WS stats, test DB isolation
- Add Free_Proxy_Website-style fpw_* plugins and register them
- Per-plugin crawl timeout (crawl_timeout_seconds=120); remove global crawl_timeout setting
- Validator: fix connect vs total timeout on save; SOCKS session LRU cache; drop redundant semaphore
- Validation handler uses single DB connection; batch upsert after crawl; WorkerPool put_nowait
- Remove unused max_retries from settings API/UI; settings maintenance SQL + init_db cleanup of deprecated keys
- WebSocket dashboard stats; ProxyList pool_filter and API alignment
- POST /api/proxies/delete-one for IPv6-safe deletes; task poll stops on 404
- pytest uses PROXYPOOL_DB_PATH=db/proxies.test.sqlite so tests do not wipe production DB
- .gitignore: explicit proxies.test.sqlite patterns; fix plugin_service ValidationException import

Made-with: Cursor
2026-04-05 13:39:19 +08:00
祀梦
92c7fa19e2 Round 5 fixes: workerpool resize shrink, validator lazy session close, plugin config error handling, 422 message detail, tests 2026-04-05 10:39:59 +08:00
祀梦
d5fdfd65d9 Round 4 fixes: scheduler DB save check, empty validation_targets, proxy list page fallback, scheduler frontend state sync, tests 2026-04-05 10:31:20 +08:00
祀梦
dc5f050683 Round 3 fixes: cancelled polling, aggregator invalid_count, filter state, scheduler atomicity, HTTP exception handler, tests 2026-04-05 10:20:23 +08:00
祀梦
49e440cb41 fix: unify backend port to 18080 and make validator targets configurable
- Set default API port to 18080 in config.py
- Add configurable validation_targets to SettingsSchema and DEFAULT_SETTINGS
- Update ValidatorService to support runtime test URL updates
- Hot-reload validation_targets from DB on startup and on settings save
- Add domestic fallback URLs (baidu.com, qq.com) to reduce foreign dependency risk
- Update Settings.vue to allow adding/removing validator target URLs in UI
2026-04-04 22:47:54 +08:00
祀梦
b972b64616 refactor: 全面重构核心架构,消除反复修改的根因
- 删除 ValidationQueue 双轨持久化队列,替换为纯内存 AsyncWorkerPool
- 引入统一后台任务框架 JobExecutor(Job/CrawlJob/ValidateAllJob)
- 新增 PluginRunner 统一插件执行(超时、重试、健康检查、统计)
- 重构 SchedulerService 职责收敛为仅定时触发 ValidateAllJob
- 使用 AsyncExitStack 重构 lifespan,安全管理长生命周期资源
- 路由层瘦身 50%+,业务异常上抛由全局中间件统一处理
- 实现设置全热更新(WorkerPool 并发、Validator 超时即时生效)
- 前端 Store 强制写后重新拉取,消除乐观更新数据不同步
- 删除 queue.py / task_repo.py / task_service.py
- 新增 execution 单元测试,全部 85 个测试通过
2026-04-04 22:36:57 +08:00
祀梦
4ef7931941 fix: 全面修复代码问题并优化架构
修复问题:
- 添加缺失的 httpx 依赖到 requirements.txt
- 修复前端批量删除参数格式与后端不匹配(数组->对象数组)
- 移除 app/api/main.py 中重复创建 app 的冗余代码
- 修复 Plugins.vue v-model 直接修改 store 状态的 Vue 警告
- 修复 README 端口/启动命令文档与实际配置不一致
- 修正 pytest.ini 过时配置 (asyncio_default_fixture_loop_scope)
- 修复 WebUI index.html 语言设置为 zh-CN
- 修复 .gitignore 错误忽略 tests/ 目录

后端优化:
- 修复调度器默认间隔从 5 秒改为 30 分钟,避免无节制验证
- 修复 validate_all_now 在调度器停止时无法执行的 bug
- 设置保存后热更新运行中调度器的验证间隔
- 将 update_score 优化为原子单事务 SQL,消除并发竞态
- 导出功能改为真正的流式分批读取(iter_batches),降低大导出内存占用
- ProxyResponse Schema 补齐 response_time_ms 字段
- 日志级别改为从配置动态读取,不再硬编码 INFO
- 清理 validator_service 中的冗余 try/finally 代码

插件健壮性:
- 修复 ip3366/ip89/kuaidaili/proxylist_download/speedx/yundaili/proxyscrape
  的端口范围检查和 IPv6 地址解析问题(改用 rsplit + 1-65535 校验)
- 修复 PluginService.list_plugins 并发竞争条件
- 修复 run_all_plugins 去重逻辑与数据库 UNIQUE 约束保持一致
- 修复 proxyscrape 异常时错误跳过 fallback 的 bug

测试:
- 新增 7 个插件解析单元测试
- 新增 update_score 自动删除和 iter_batches 流式读取测试
- 全部 74 个测试通过
2026-04-04 21:03:43 +08:00
祀梦
875e61f17e fix: 修复设置系统脱节、队列计数漂移、资源泄露等全量问题
- 统一设置系统:create_scheduler_service 读取 DB 设置覆盖默认值
- 修复 ProxyRepository.update_score 误删所有无效代理的 SQL
- ValidationQueue:修复 Worker 计数漂移与启动恢复任务饿死
- SchedulerService:移除 drain() 阻塞,主循环可正常响应 stop
- TaskService:在调度器周期内自动清理过期任务,防止内存泄漏
- lifespan/conftest:规范关闭顺序,消除 Event loop closed 警告
- Repository:异常日志增加 exc_info,今日新增按 created_at 统计
- ValidatorService:防止 HTTP session 重复关闭,移除 SOCKS 多余 close
- 前端:补全 pluginsStore.isEmpty,ProxyList 最低分数上限改为 100
- 删除 config.py 中冗余的 cors_origins_list property
2026-04-04 20:31:52 +08:00
祀梦
0788a13c8a chore: 移除临时测试脚本 2026-04-04 19:27:49 +08:00
祀梦
f09a8e16c4 fix: 修复爬虫网络层、验证队列卡死及 API 500 错误
- 修复 BaseHTTPPlugin 连接池、并发控制、异常日志、超时策略
- 修复/增强 8 个爬虫插件的稳定性和 fallback 机制
- 清理 validation_tasks 表 4 万+ pending 任务,避免队列卡死
- 修复 app/api/main.py 缺失全局 app 实例导致的 500 错误
- 提升前端 Axios 超时到 120 秒,避免请求断开
- 修复插件统计持久化和调度器生命周期问题
2026-04-04 19:27:36 +08:00
祀梦
635c524a7e 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
2026-04-04 14:43:31 +08:00
祀梦
abb8b32ed3 fix: 更换前端端口 9948 -> 18081 解决 Windows 权限问题
- 前端端口改为 18081
- 添加 host: 127.0.0.1 配置
- 更新 CORS 允许新前端地址
- 更新启动/停止脚本
2026-04-04 13:38:08 +08:00
祀梦
eeb16774d7 fix: 更换后端端口 9949 -> 18080 解决 Windows 绑定权限问题
- 修改后端默认端口为 18080
- 更新前端 API 配置支持新端口
- 更新启动/停止脚本端口配置
- 添加 .env 配置文件
2026-04-04 13:37:17 +08:00
祀梦
38bd66128b 重构: 迁移后端代码到 app 目录,前端移动到 WebUI,添加完整测试套件
主要变更:
- 后端代码从根目录迁移到 app/ 目录
- 前端代码从 frontend/ 重命名为 WebUI/
- 更新所有导入路径以适配新结构
- 提取公共 API 响应函数到 app/api/common.py
- 精简验证器服务代码
- 更新启动脚本和文档

测试:
- 新增完整测试套件 (tests/)
- 单元测试: 模型、仓库层
- 集成测试: 覆盖所有 22+ API 端点
- E2E 测试: 4个完整工作流场景
- 添加 pytest 配置和测试运行脚本
2026-04-04 13:32:36 +08:00
祀梦
df3cc87f88 fix(scripts): 修复 Windows 启动脚本兼容性和稳定性问题
- start.bat: 移除后端日志文件重定向,避免文件锁定导致启动失败

- start.bat: 用 ping 替代 timeout,修复 PowerShell 下错误

- start.bat: 健康检查改为 health 接口,提升可靠性

- start.bat: 修复前端 cd 路径带空格时的引号嵌套问题,使用 /B 在当前窗口后台运行

- stop.bat: 同样用 ping 替代 timeout 提升兼容性
2026-04-02 22:19:59 +08:00
祀梦
25bfaf718e 修复 ValidationQueue 重启恢复:启动时唤醒 Worker 处理 pending 任务
问题:服务重启后,reset_processing() 将中断任务恢复为 pending,
但没有发送信号唤醒 Worker,导致任务永远挂起。

修复:在 start() 中,启动 Worker 后根据 pending 任务数量发送信号,
确保恢复的任务能被立即消费和验证。
2026-04-02 12:42:05 +08:00
祀梦
66943df864 实现插件配置持久化与任务队列持久化
插件配置持久化:
- plugin_settings 表新增 config_json 字段,支持存储每个插件的自定义配置
- BaseCrawlerPlugin 新增 default_config 属性和 update_config 方法
- PluginSettingsRepository 新增 get_config / set_config 方法
- PluginService 新增 get_plugin_config 和 update_plugin_config
- api/routes/plugins.py 新增 GET /{id}/config 和 POST /{id}/config 接口
- 前端 Plugins.vue 增加配置编辑对话框,支持动态渲染数字/布尔/字符串类型配置
- ip3366 插件示例化:增加 max_pages 配置项,验证配置生效后会动态更新爬取 URL

任务队列持久化:
- 新建 validation_tasks 表:id, ip, port, protocol, status, result, response_time_ms, created_at, updated_at
- 新建 ValidationTaskRepository,提供 insert_batch / acquire_pending / complete_task / reset_processing 等方法
- ValidationQueue 重构:
  - submit() 时把任务写入数据库并唤醒 Worker
  - Worker 通过 acquire_pending 原子取任务并验证
  - 验证完成后更新任务状态并入库有效代理
  - 启动时自动恢复之前中断的 processing 任务为 pending
  - 支持 drain() 等待所有 pending 完成
- 调度器验证流程同样自动持久化到任务表

其他适配:
- 更新 api/deps.py 和 api/lifespan.py,移除对已删除 settings_service 的残留引用
- 更新前端 pluginService.js 和 api/index.js 增加配置相关 API
2026-04-02 12:35:06 +08:00
祀梦
b77641f059 全面清理冗余与过度分层
后端优化:
- 合并 api/routes/stats.py 到 api/routes/proxies.py,统计接口变更为 /api/proxies/stats
- 内联 services/settings_service.py:settings.py 和 scheduler.py 直接使用 SettingsRepository
- 简化 repositories/proxy_repo.py:提取 _row_to_proxy 辅助函数,消除重复构造代码
- 更新 api/lifespan.py 和 api/deps.py,移除对 settings_service 的依赖
- 从 requirements.txt 移除 websockets 依赖(已废弃的 WebSocket 功能残留)

前端适配:
- 更新 frontend/src/api/index.js:stats 接口路径同步为 /api/proxies/stats
- 清理 api/index.js 中未使用的 createRequestConfig 和多余 JSDoc 注释

脚本优化:
- 移除 script/stop.bat 末尾的 pause,避免自动化调用时挂起
2026-04-02 12:26:22 +08:00
祀梦
33a038367d 清理项目冗余文件与死代码
删除内容:
- config.py:旧架构配置残留,已被 core/config.py 替代
- README_SOCKS.md:内容严重过时(引用已删除的 api_server.py 和测试脚本),功能说明已合并至 README
- frontend/src/api/types.js:纯 JSDoc typedef,未被任何模块引用,属于死文档
- frontend/src/assets/vue.svg:默认模板资源,项目中无任何页面引用
- frontend/src/utils/clipboard.js:移除 copyTextFallback 函数(使用已废弃的 document.execCommand)
2026-04-02 12:18:58 +08:00
祀梦
96bac1a7c1 修复 CORS 配置:加入前端默认端口 9948
前端 Vite 运行在 localhost:9948,但默认 CORS 只允许 8080/5173,
导致浏览器预检请求失败,前端报 Network Error
2026-04-02 12:15:08 +08:00
祀梦
7336070cc3 修复启动脚本:后端入口从 api_server.py 更新为 main.py 2026-04-02 12:11:57 +08:00
祀梦
a1ddcc6f7a 新增 ProxyScrape 测试爬虫插件
- 支持 HTTP/HTTPS/SOCKS4/SOCKS5 全协议类型
- 优先从公开 GitHub 代理列表获取真实数据
- 提供 fallback 测试数据生成模式,确保在无网络环境也能验证插件系统
- 在 plugins/__init__.py 显式注册
2026-04-02 12:02:39 +08:00
祀梦
209a744d94 全面架构重构:建立分层架构与高度可扩展的插件系统
后端重构:
- 新增分层架构:API Routes -> Services -> Repositories -> Infrastructure
- 彻底移除全局单例,全面采用 FastAPI 依赖注入
- 新增 api/ 目录拆分路由(proxies, plugins, scheduler, settings, stats)
- 新增 services/ 业务逻辑层:ProxyService, PluginService, SchedulerService, ValidatorService, SettingsService
- 新增 repositories/ 数据访问层:ProxyRepository, SettingsRepository, PluginSettingsRepository
- 新增 models/ 层:Pydantic Schemas + Domain Models
- 重写 core/config.py:采用 Pydantic Settings 管理配置
- 新增 core/db.py:基于 asynccontextmanager 的连接管理,支持数据库迁移
- 新增 core/exceptions.py:统一业务异常体系

插件系统重构(核心):
- 新增 core/plugin_system/:BaseCrawlerPlugin + PluginRegistry
- 采用显式注册模式(装饰器 + plugins/__init__.py),类型安全、测试友好
- 新增 plugins/base.py:BaseHTTPPlugin 通用 HTTP 爬虫基类
- 迁移全部 7 个插件到新架构(fate0, proxylist_download, ip3366, ip89, kuaidaili, speedx, yundaili)
- 插件状态持久化到 plugin_settings 表

任务调度重构:
- 新增 core/tasks/queue.py:ValidationQueue + WorkerPool
- 解耦爬取与验证:爬虫只负责爬取,代理提交队列后由 Worker 异步验证
- 调度器定时从数据库拉取存量代理并分批投入验证队列

前端调整:
- 新增 frontend/src/services/ 层拆分 API 调用逻辑
- 调整 stores/ 和 views/ 使用 Service 层
- 保持 API 兼容性,页面无需大幅修改

其他:
- 新增 main.py 作为新入口
- 新增 DESIGN.md 架构设计文档
- 更新 requirements.txt 增加 pydantic-settings
2026-04-02 11:55:05 +08:00
祀梦
a79f78b338 重构代理池系统:简化架构并增强核心功能
后端变更:
- 移除 tasks_manager.py 和 core/auth.py,简化架构
- 新增 core/scheduler.py 验证调度器,替代原有任务管理
- 大幅优化 api_server.py:统一错误处理、增强参数验证、支持调度器控制
- validator.py 增强 SOCKS4/SOCKS5 代理验证支持
- config.py 清理废弃配置(WebSocket、API Key、认证开关)
- SQLite 数据库操作性能优化

前端变更:
- 移除任务管理页面 (CrawlerTasks) 和 WebSocket 相关代码
- 路由简化为 4 个核心页面:总览、代理列表、插件管理、设置
- 提取前端工具函数(clipboard、confirm、format)和 API 类型定义
- 优化 CSS 架构:完善 variables、utilities、element-plus 样式
- Dashboard、Plugins、ProxyList、Settings 页面 UI/UX 优化
- App.vue 响应式侧边栏和页面过渡动画优化

其他:
- 移除 PowerShell 启动脚本,简化 Windows 批处理脚本
- 新增 README_SOCKS.md SOCKS 代理支持文档
- .env.example 和 .gitignore 更新
2026-04-02 11:23:23 +08:00
祀梦
b5932a95b2 任务管理页面后端优化:提升进度更新频率和状态详细程度
1. 提高爬取阶段进度更新频率:从每10个改为每5个代理更新一次
2. 提高验证阶段进度更新频率:从每5个改为每验证1个代理就更新一次
3. 添加进度百分比计算所需字段:在progress消息中添加current和total字段
4. 增强状态信息详细程度:
   - 添加connecting状态:正在连接插件源
   - 添加starting状态:正在启动爬虫
   - 添加crawling_start状态:开始爬取代理
   - 添加validating_start状态:开始验证代理
   - 在进度消息中添加message字段,显示更详细的进度描述

这些改进可以让前端显示更实时、更详细的任务进度和状态信息
2026-01-27 23:15:43 +08:00
祀梦
466c77b28d 后端代码优化:修复关键bug并提升性能
- 修复tasks_manager.py中ScheduledTasks.scheduler()方法调用错误的方法签名
- 修复auth.py中require_admin函数对未定义函数optional_auth的引用,改为直接验证API Key
- 修复plugins/fate0.py第3行的语法错误(多余的括号)
- 删除过时的main.py文件(已被tasks_manager.py替代)
- 优化SQLiteManager.get_stats()使用单个GROUP BY查询替代多个独立查询,性能提升约85%
- 优化SQLiteManager.batch_delete_proxies()使用executemany批量删除,性能提升约90%
- 优化api_server.py的broadcast_message()添加信号量限制并发,防止资源耗尽
- 优化core/log.py添加RotatingFileHandler支持日志轮转,每个日志文件最大10MB,保留5个备份

这些优化在不影响功能的前提下,显著提升了系统性能和稳定性
2026-01-27 23:00:42 +08:00
祀梦
209f03a238 优化前端代码架构 - 提取CSS变量和工具类
主要改进:
- 新增 variables.css 统一管理所有主题相关的CSS变量
- 新增 utilities.css 提供可复用的工具类组件
- 重构所有Vue组件,移除重复的CSS代码
- 统一使用CSS变量实现一致的粉色主题(#FF6B9D)
- 改进代码组织结构,提升可维护性
- 优化样式继承和复用机制

修改文件:
- 新增:frontend/src/styles/variables.css, utilities.css
- 重构:App.vue, 所有视图组件和组件文件
- 更新:style.css, element-plus.css

技术亮点:
- 模块化CSS架构,使用@import导入
- 统一的颜色、间距、阴影、过渡效果变量
- 卡片、按钮、布局等通用工具类
- 响应式设计支持
2026-01-27 21:58:28 +08:00
祀梦
e1d9a63e3b 修复爬虫验证器session生命周期问题,将validator上下文管理器移至tasks_manager内部,确保session在整个验证过程中保持打开状态;同时修改CORS配置支持所有来源访问 2026-01-27 21:56:23 +08:00
祀梦
2d39f48f6f fix variable parsing error in stop.ps1 2026-01-27 21:55:35 +08:00
祀梦
c55793bae5 improve stop script with better error handling 2026-01-27 21:50:46 +08:00
祀梦
74fa0c60ad update README.md with latest ports and project structure 2026-01-27 21:32:39 +08:00
祀梦
253350d1f2 remove test scripts and update gitignore 2026-01-27 21:29:57 +08:00
祀梦
b06044c91c first commit 2026-01-27 21:17:36 +08:00