P1: 架构加固

- 线程池服务器: 连接级读写超时 + 有界队列(BoundedSemaphore),拒绝慢速/洪水连接
- 镜像代理流式转发(64KB 分块 + 4GB 上限),小响应才内存缓存(16MB 上限)
- _serve_cached 支持单段 Range(206);pypi 下载流式化;docker urlopen 补超时
This commit is contained in:
HYC Fixer
2026-08-30 12:23:29 +08:00
parent 084164296d
commit 237b99b480
4 changed files with 588 additions and 501 deletions
+2 -2
View File
@@ -141,7 +141,7 @@ class DockerMirror:
auth = base64.b64encode(f"{self.username}:{self.password}".encode()).decode()
req.add_header('Authorization', f"Basic {auth}")
with urllib.request.urlopen(req) as response:
with urllib.request.urlopen(req, timeout=60) as response:
data = response.read()
# 缓存
@@ -189,7 +189,7 @@ class DockerMirror:
auth = base64.b64encode(f"{self.username}:{self.password}".encode()).decode()
req.add_header('Authorization', f"Basic {auth}")
with urllib.request.urlopen(req) as response:
with urllib.request.urlopen(req, timeout=60) as response:
data = response.read()
# 缓存