docs(architecture): phase 2 batch 6B — integration & runtime trio#185
Merged
Conversation
#167) 撰写架构介绍剩余 9 篇中的 6B 三篇:CLIProxyAPI 集成位置、安全模型、国际化机制。 全部以源码事实为依据,标注真实 file:line 引用,避免凭经验推断。 - cliproxy-integration: 数据模型(2 张表 + upstreams 三字段)、服务模块六文件分工、 OAuth 账号同步流程、转发路径中的 CPA 分支、受管 sidecar 与外部模式差异(地址校验 + 容器编排)、连通性检测分离、Admin API 全貌、前端入口 - security: 管理员鉴权(静态 Bearer)、客户端 Key 双轨存储(bcrypt + Fernet)、揭示 双闸门策略、上游 Key Fernet 加密格式与调用点、SSRF 三重校验(IP/URL/DNS)、CORS、 中间件 matcher 排除 /api、登录会话基于 sessionStorage - i18n: next-intl 配置四文件、根 vs locale layout 分工、middleware matcher、19 个 顶层 namespace、客户端/服务端使用模式、语言切换组件保留 query string、文档站 i18n 与应用 i18n 完全独立的边界 合入后架构介绍进度:6/9 已合入(含 6A 三篇),剩余 3 篇(testing + contributing + release)由 6C 批次跟进。
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #185 +/- ##
=======================================
Coverage 74.14% 74.14%
=======================================
Files 145 145
Lines 11043 11043
Branches 3832 3832
=======================================
Hits 8188 8188
Misses 1657 1657
Partials 1198 1198
🚀 New features to boost your workflow:
|
…e per codex review (#167) 修正 PR #185 codex review 指出的两处与现状不符: - 实例删除:原文写「FK ON DELETE SET NULL 清空三列」与实际行为相反。 deleteCliproxyInstance 在删除前依次校验关联账号与关联上游,任一不为空即抛 CliproxyInstanceInUseError 拒绝删除,FK 在正常路径下从不触发。另外三个 CPA 关联列中只有 cliproxyInstanceId 带 FK,cliproxyAuthFileName 与 cliproxyProvider 是纯文本,删除实例后不会自动清理。 - external 模式 SSRF:原文称「三重 SSRF 校验」过度声称。validateInstanceAddress 在 external 分支只调用同步的 isUrlSafe,不执行 resolveAndValidateHostname,因此 恶意域名解析到私有/元数据地址理论上能绕过校验。修正为两重校验的实际范围,并 补充与普通上游路径的对比,避免读者把安全保证当作既成事实。
14 tasks
g1331
added a commit
that referenced
this pull request
May 25, 2026
…卷挂载现状 (#167, #188) Self-review 抽读时发现四处与仓库现状不符的事实陈述,本次一并修正: 1. database.md / upgrade-rollback.md 关于「容器不会自动跑迁移」「需要部署人手工触发 pnpm db:migrate」的描述与 scripts/docker-entrypoint.sh 现状矛盾。 该 entrypoint 在应用启动前会自动跑一遍内嵌的 migration runner(不依赖 drizzle-kit,按文件名顺序 apply drizzle/*.sql、用 __drizzle_migrations 表去重)。改为说明自动 apply 行为,并把破坏性迁移段重写为「entrypoint 仍 forward apply,回滚必须靠 pg_dump」。 2. database.md / upgrade-rollback.md 建议的 `docker compose exec autorouter node node_modules/drizzle-kit/bin.cjs migrate` 在生产镜像内无法执行。 Dockerfile standalone runner stage 只 copy postgres 这一个 node_modules 子包,drizzle-kit 是 devDependency 不进镜像。改为推荐「重启 autorouter 让 entrypoint 重跑」或「docker run --rm --entrypoint /app/docker-entrypoint.sh ghcr.io/g1331/autorouter:vN.N.N true」这种把 entrypoint 与 server.js 解耦的临时容器写法。 3. persistence-backup.md 关于「RECORDER_FIXTURES_DIR 通常会挂入 autorouter-data named volume(如默认编排)」的描述错误。 docker-compose.yml 中 RECORDER_FIXTURES_DIR 默认值是 `tests/fixtures`,相对容器内 /app/,实际写到 /app/tests/fixtures,不在任何 named volume 上——容器重建即丢。补 ::: danger ::: 容器警告,并显式给出「显式把 RECORDER_FIXTURES_DIR 指到 /app/data/...」的修复路径。 4. contributing.md 关于「推荐用 squash merge」与仓库实际 merge commit 历史(PR #184/#185/#186 都是 Merge pull request 形态)冲突。改为陈述「近期实际历史以 merge commit 为主,cliff.toml 显式 skip 这类 commit」,把策略选择留给 reviewer。 来源对照段同步补 scripts/docker-entrypoint.sh 与 Dockerfile 两项依据。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
Issue #167 Phase 2 架构介绍批次推进。6A 已合入 3 篇核心机制(upstream-model + failover-circuit + database-schema);本 PR 是 6B 集成与运行时三件套,覆盖 CPA 集成、安全模型、国际化机制。
改动
补齐三篇架构占位页的正文,全部以源码事实为依据,所有断言都标注真实
file:line引用,避免凭经验推断。docs/guide/architecture/cliproxy-integration.mdcliproxy_instances+cliproxy_auth_accounts两张表完整字段,以及upstreams表的三个 CPA 关联字段is_cliproxy_pool标志位,按 `cliproxyInstanceId` + `cliproxyAuthFileName` 组合判定)docs/guide/architecture/security.mddocs/guide/architecture/i18n.md校验
合入后状态
Refs #167