Commit Graph
22 Commits
Author SHA1 Message Date
nyaKazuhaandClaude Fable 5 b570f37359 fix(official-sync): 区分代理故障并前置校验代理配置
- 代理故障分类:curl 因代理 407 认证失败(CONNECT 隧道失败)、无法解析/连接
  代理等,原被归为普通可重试网络错误,永不成功也会耗尽 per-URL 重试且无诊断。
  新增 CurlFailureKind::Proxy,从 curl stderr 识别代理故障,per-URL 层 fail-fast
  不重试(daemon error-retry 循环仍整体重试以覆盖代理短暂抖动),并在失败摘要里
  以 kind=proxy 明确标注。
- 前置校验:parse_proxy_config 新增 validate_proxy_url,拒绝拼错的代理 scheme
  (如 htp://),只接受 http/https/socks4/socks4a/socks5/socks5h 或无 scheme
  的 host:port。
- doctor:proxy 检查不再恒 ok,对解析出的代理 URL(含 auto 从环境变量取得的)
  做 scheme 校验,前置暴露配置错误。

新增单测:代理 407/解析失败归为 Proxy 且不重试、源站连接失败仍为 Connect 可重试、
拒绝不支持的 scheme、无 scheme host:port 接受。

对应 issue #18 维护清单 2-5。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-16 08:18:37 -07:00
nyaKazuhaandClaude Fable 5 3cb3637749 fix(official-sync): 清理未被引用的孤儿 staging 目录
同版本失败 staging 复用已由 060b7d7 处理,但跨版本失败、或被 trim/去重挤出
failed_versions 记录后残留的 .staging/<id> 目录永不被复用也无人清理,长期 daemon
场景下多 GB 孤儿目录会累积耗尽磁盘。

新增 gc_orphan_staging:枚举 .staging 下子目录,只保留 in_progress_version 与
failed_versions 引用的 <id>,删除其余(跳过普通文件与 symlink,staging 根不存在
时无操作)。在同步成功发布后(读取最新版本状态)和 clean-stable(后台已停止)两处
调用;GC 失败仅告警,不影响发布结果。

对应 issue #18 维护清单 1-4。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-16 07:29:37 -07:00
nyaKazuhaandClaude Fable 5 55b9babb66 fix(official-sync): 代理凭据改由环境变量下传子进程
彻底收敛 1-2 的两处残留凭据暴露:

- 子进程 argv:daemon_child_args 不再把 --proxy <url> 写入子进程参数,改为
  只放不含凭据的内部 flag --proxy-from-env,真实 URL 经 BAT_OFFICIAL_SYNC_PROXY_URL
  环境变量下传。凭据从世界可读的 /proc/<pid>/cmdline(0444)转移到仅属主可读的
  /proc/<pid>/environ(0400);子进程解析后立即 env::remove_var,避免被 curl 等
  孙进程继承。
- 状态文件 at-rest:0600 状态文件的 command 字段不再含凭据。restart/reload 复用
  所需的 URL 改存专用 0600 文件 bat-proxy.secret,该文件永不进入状态输出或 --json;
  clean-stable 会在后台停止后清除它。

复用型 restart/reload 从 bat-proxy.secret 还原代理;凭据文件缺失时(如 clean-stable
后)明确报错要求重新传入 --proxy,而非静默丢弃代理。

验证:新增 curl_proxy_url、secret 文件 0600 往返、--proxy-from-env 读取并清除
环境变量的单测;真机起停 daemon 确认凭据不在 cmdline/状态文件/status --json,
仅在 0600 secret 文件与 owner-only environ;复用 restart 成功还原、clean-stable
后复用 restart 明确报错。

对应 issue #18 维护清单 1-2 残留项。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-16 05:20:22 -07:00
nyaKazuhaandClaude Fable 5 810b39c2cd fix(official-sync): 修复阻塞 clippy 门禁的两处告警
cargo clippy --workspace -- -D warnings 在 HEAD 上失败,阻塞项目验证门禁:
- resolve_bootstrap 因 c123f6c 新增 curl_proxy 参数达到 8 个,触发
  too_many_arguments。将 curl_command/curl_proxy/unzip_command 收拢为
  BootstrapTools 结构体,降到 6 个参数。
- visible_historical_failed_versions(169822a 引入)的显式生命周期可省略,
  触发 needless_lifetimes。按 clippy 建议省略。

对应 issue #18 维护清单 1-7。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-16 04:40:35 -07:00
nyaKazuhaandClaude Fable 5 eef8c52497 fix(official-sync): 脱敏代理凭据避免泄漏到日志与状态输出
两处代理凭据泄漏:
- redact_proxy_url 对无 scheme 的代理串(user:secret@host:port,curl 默认按
  http 处理)完全不脱敏,明文凭据会进入 progress 事件、daemon 日志和
  bat-events.jsonl。现对无 scheme 但含 userinfo 的情况一并脱敏。
- daemon 保存的 command 含原始代理 URL,经 RPC status 和 bat status --json
  回显到 stdout(会被监控采集)。新增 redact_command_proxy_credentials,在
  build_daemon_status_report 的对外拷贝里脱敏 --proxy 值;磁盘状态文件
  (0600)仍保留原始 command 供 restart/reload 复用。

残留:子进程 argv 仍可经 /proc/<pid>/cmdline 读到代理凭据,以及 0600 状态
文件内的 at-rest 凭据,二者受进程属主与文件权限约束,后续可改由环境变量下
传子进程进一步收敛。

对应 issue #18 维护清单 1-2。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-16 04:31:10 -07:00
nyaKazuha c123f6c0dc feat(official-sync): 支持本地代理下载官方资源 2026-07-16 00:12:27 +08:00
nyaKazuha 169822abaf fix(daemon): 区分当前下载与历史失败状态 2026-07-15 23:22:30 +08:00
nyaKazuha 5b31112e91 fix(daemon): 使用人类格式输出 RPC 下载进度 2026-07-15 23:05:28 +08:00
nyaKazuha 7890b667d7 fix(daemon): 去重失败版本并优化状态输出 2026-07-15 22:32:27 +08:00
nyaKazuha 90307a3243 feat: track official versions and import resources
Persist official version-state, extend CAS/ResourceRepository import classification, and add offline catalog and failure regression fixtures.

Fixes #13

Fixes #12

Fixes #8
2026-07-15 19:53:10 +08:00
nyaKazuha 4192d7ee4c fix: classify official download failures
Distinguish terminal HTTP errors from retryable CDN/network failures, record quarantined resources, and report failed download progress.

Fixes #7
2026-07-14 01:30:12 +08:00
nyaKazuha 2ff99ae9e3 feat: publish official resources atomically
Fixes #9

Fixes #11
2026-07-14 00:10:39 +08:00
nyaKazuha 45aba2fb2b fix: harden official sync filesystem boundaries
Fixes #14
2026-07-13 23:17:52 +08:00
nyaKazuha 599ead8391 fix: serialize daemon control commands
Fixes #10
2026-07-13 22:02:11 +08:00
nyaKazuha 1bcb9c828a feat: summarize official validation results
Fixes #5
2026-07-13 01:06:37 +08:00
nyaKazuha e5fcf26e19 feat: validate official zip structure 2026-07-12 23:37:47 +08:00
nyaKazuha f7255f7c04 feat: improve bat daemon cli output 2026-07-12 23:04:13 +08:00
nyaKazuha 264e78c440 feat: harden official sync scheduling and integrity 2026-07-11 01:06:02 +08:00
nyaKazuha f704ec18c5 feat: add official sync startup banner 2026-07-07 23:00:02 +08:00
nyaKazuha ea0920e4e3 feat: add official sync progress logging 2026-07-07 22:13:07 +08:00
nyaKazuha b2d6871926 fix: harden official resource sync retries 2026-07-07 01:14:54 +08:00
nyaKazuha 789402c887 feat: add official resource sync pipeline
Add the production-facing official update service and bat-official-sync watch CLI for unattended resource synchronization.

Support launcher-resource discovery without installing the launcher, remote marker snapshots, local manifest audit and repair, official seed hash validation, bootstrap caching, richer Addressables coverage, SQLite resource persistence, and FFI JSON helpers.
2026-07-05 23:49:56 +08:00