- 统一设置系统: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
45 lines
1.1 KiB
Python
45 lines
1.1 KiB
Python
"""领域模型 - 纯数据结构,不依赖任何框架"""
|
|
from dataclasses import dataclass, field
|
|
from datetime import datetime
|
|
from typing import Optional
|
|
|
|
|
|
@dataclass
|
|
class ProxyRaw:
|
|
"""爬虫爬取的原始代理数据"""
|
|
ip: str
|
|
port: int
|
|
protocol: str = "http"
|
|
|
|
def __post_init__(self):
|
|
self.protocol = self.protocol.lower().strip()
|
|
if self.protocol not in ("http", "https", "socks4", "socks5"):
|
|
self.protocol = "http"
|
|
if not isinstance(self.port, int) or not (1 <= self.port <= 65535):
|
|
raise ValueError(f"port must be between 1 and 65535, got {self.port}")
|
|
|
|
|
|
@dataclass
|
|
class Proxy:
|
|
"""数据库中的代理实体"""
|
|
ip: str
|
|
port: int
|
|
protocol: str
|
|
score: int
|
|
response_time_ms: Optional[float] = None
|
|
last_check: Optional[datetime] = None
|
|
created_at: Optional[datetime] = None
|
|
|
|
|
|
@dataclass
|
|
class PluginInfo:
|
|
"""插件元数据"""
|
|
id: str
|
|
name: str
|
|
display_name: str
|
|
description: str
|
|
enabled: bool
|
|
last_run: Optional[datetime] = None
|
|
success_count: int = 0
|
|
failure_count: int = 0
|