Commit Graph
24 Commits
Author SHA1 Message Date
Qiu Yuzhou 39e25477bb feat(proxy): add ACL-backed direct mode 2026-09-26 11:46:45 +08:00
Qiu Yuzhou 41379bb1cb fix(ng2): review fixes for agent/system-proxy switch split
- setAgentEnabled(true) 在意图已开启且未达健康态(off/启动失败/服务
  失败)时执行重收敛,成为失败态的显式重试入口;健康运行中不做无谓
  的注销重拉
- StatusMenuModel.Summary 增加 systemProxyStateLabel 短标签,去掉
  HomeView 对呈现文本的字符串剥离耦合
- 控制器头注释改为如实描述:launchd/契约动作序列在 ProxyRuntimePlan,
  系统代理门禁收敛决策留在控制器(issue #60)
- 新增重试路径测试
2026-09-26 00:55:52 +08:00
Qiu Yuzhou 398e8d84b6 feat(ng2): split agent and system proxy switches
实现 #60(ACL 1/8):agent 意图与系统代理意图拆为两个独立开关,
首次运行默认 agent 开、系统代理关;显式关闭 agent 持久化并在 GUI
重启后生效;关闭系统代理只恢复 NG2 持有的系统设置,本地 SOCKS/HTTP
继续监听;关闭 agent 先恢复系统设置再停止监听。无活动目标时 agent
以空服务器列表契约提供本地监听(isWellFormed 放行空 servers,上游
sslocal v1.25.0 接受);需要代理出口的模式在活动目标缺失或端点不健
康时系统代理保持待应用,条件恢复后随下次收敛自动应用。首页、状态菜
单与侧栏状态卡经同一代理控制快照展示/操作 agent 意图/运行状态与系
统代理意图/实际应用及 typed 错误。测试覆盖启动顺序、持久化、健康门
禁、ownership 冲突、无效活动目标与 GUI 重同步(含真实 sslocal 空监
听回环证据);替身测试不表述为真实系统写入验证。
2026-09-26 00:38:28 +08:00
Qiu Yuzhou c76ba93221 feat(ng2): finalize settings workflow persistence boundary 2026-09-24 00:20:42 +08:00
Qiu Yuzhou 9fc6446237 refactor(ng2): remove manual and external PAC 2026-09-23 18:47:15 +08:00
Qiu Yuzhou e65d7112f1 refactor(ng2): unify committed catalog source 2026-09-23 16:47:13 +08:00
Qiu Yuzhou 6c98930999 refactor(ng2): unify runtime facts and proxy mode availability 2026-09-23 11:48:13 +08:00
Qiu Yuzhou fe4c3e166e refactor(ng2): centralize typed failure presentation 2026-09-23 10:51:26 +08:00
Qiu Yuzhou cdf1c8ab8f refactor(ng2): deepen catalog policy into workflow seam
New UI must bind projections and send typed commands only.
Views were re-deriving delete confirm, move destinations,
activation eligibility, and drag payload from domain state.

Empty manual-group delete is no longer instant — always one confirmation.
2026-09-22 20:41:18 +08:00
Qiu Yuzhou 3df1624d91 refactor(ng2): add settings workflow module as single UI-facing seam
建立设置工作流深 module(App/SettingsWorkflow/),把设置编辑的编排从视图
收拢到一个 seam,镜像 #41 的目录工作流模式:

- UI-facing interface:可编辑 draft 投影(binding 直连)、占用/校验/门禁/
  保存中/待确认 PAC 失效提示/错误等只读投影,与 suggestPort、save、
  confirmPACNotice、cancelPACNotice、reset、reloadFromCommitted 等 typed
  command;登录启动项是独立偏好域(ADR-0005),视图直连其控制器,不经本
  module。
- implementation(灰置):端口占用探测的 Task.detached 编排(代际去竞态)、
  保存门禁(validationErrors+占用)、「当前运行端口」例外、PAC 失效确认
  流、重置事务与 ProxySettingsStoreError 文案映射。
- isOn 判定从 StatusMenuModel 迁至 ProxyRuntimeController.ProxyState 扩展,
  菜单摘要与设置工作流共用同一事实来源;设置视图不再持有
  ProxyRuntimeController 与探测缝,组合根在 MainApp 接线一次,设置窗口
  scene 的显式触达路径不变。

测试:设置编辑 workflow 不经 SwiftUI 即可全测——占用反应与门禁阻塞、
运行端口例外放行、PAC 失效确认/取消、校验阻塞、提交失败保留旧值并点名、
重置回出厂、建议端口只写草稿(8 项;全量 376 项通过)。

Out of scope:设置视觉重设计、ProxyRuntimeController 拆分、独立编译
target。
2026-09-22 17:36:40 +08:00
Qiu Yuzhou e242bbf426 feat(ng2): persist proxy mode selection and drop enabled-modes
模式选择(菜单唯一入口)随设置快照持久化,GUI 重启恢复所选模式;持久化
失败保留旧模式并点名呈现,不静默切换。外部 PAC 模式下保存设置时,模式从
新快照解析后与 URL 一起作为一个逻辑变更提交(清空 URL 回落 PAC 并同步
持久化),校验失败先于写入。重置偏好把模式回 PAC。

enabledModes 自 ADR-0002 停止偏好迁移后无任何写入方,且 2.0 无编辑 UI,
按死状态删除:内置三模式恒可选,外部 PAC 仍以已配置的有效 URL 为门槛
(ADR-0004)。

测试:模式持久化与重启恢复、持久化失败保留旧值、外部 PAC 一个逻辑变更
回落;makeController 的 proxyMode 参数改为可选以便测试走恢复路径。
2026-09-22 17:36:24 +08:00
Qiu Yuzhou 46ebe1d835 feat(ng2): simplify Legacy import and isolate default ports (#42) 2026-09-22 14:26:58 +08:00
Qiu Yuzhou 374f0da4d7 feat(ng2): decouple catalog commit from proxy runtime sync (#40)
Add an application-layer CatalogCommitCoordinator as the single commit
entry for normal configuration changes: copy -> mutate -> atomic persist
-> publish committed state -> async runtime convergence toward the just
committed in-memory snapshot. Commits complete at persist; convergence
reports structured outcomes (converged / revalidated / failed /
clearedAndStopped) and never blocks or rolls back the commit. Each commit
bumps a generation; superseded syncs end before starting or have their
late results discarded, so only the latest snapshot can win. No automatic
retry.

CatalogRuntimeSyncing is the one new replacement seam: the production
ProxyRuntimeSyncAdapter drives the existing ProxyRuntimeController via a
snapshot-based catalogDidCommit; tests use a deterministic fake. When no
active target exists a commit no longer touches the runtime at all.

CatalogViewModel stays as a compatibility facade with unchanged published
state; the optional postCommit callback and the per-scene callback wiring
in MainApp are removed - the composition root wires the coordinator,
adapter and the (independent) Legacy import boundary exactly once.
2026-09-22 09:48:38 +08:00
Qiu Yuzhou ea801d5f38 feat(catalog): remove node enable state
Migrate legacy enabled fields to v3 without preserving their semantics.
Keep recoverable invalid imports visible and filter them during activation.
2026-09-22 08:40:13 +08:00
Qiu Yuzhou 8ec4a57deb feat(ng2): import Legacy configuration (#36) 2026-09-21 11:27:05 +08:00
Qiu Yuzhou 5e13c1716f feat(ng2): managed plugins end to end (#38)
- 受管插件静态事实表(v2ray-plugin v1.3.2,来源/许可证/版本/重签)与
  BundleManagedPluginProvider:受管集内且 bundle 内可执行文件在位才返回
  绝对路径;与 Vendor 清单双向锚定(D6/D10)
- 服务器编辑器插件区:受管选择器(无 + 受管列表),选中受管项才显示
  供应链事实与参数输入;集外引用显式「本版本未提供」并原样保留
- updateServer 插件落盘语义:「无」整体清除、参数写删钥匙串、集外不漂移
- wrapper 监听建立判定:3 秒未建立本地监听记 error 日志,监管继续(D10)
- 诊断导出新增受管插件清单(名称/版本/提供状态,无参数)
- 功能级兼容实测记录(docs/research/plugin-compat-record.md)与端到端
  冒烟:契约插件路径 → sslocal 拉起 → v2ray-plugin 进程建立 → 停止链
2026-09-21 10:38:30 +08:00
Qiu Yuzhou 2531eb35fb feat(ng2): add settings page and preferences (#33) 2026-09-21 08:54:12 +08:00
Qiu Yuzhou c3a9f62216 feat(ng2): menu bar quick actions and global shortcuts (#31)
Status menu rebuilt around the D11 eight-item whitelist: header summary
(running status, mode, active target path), proxy toggle, mode picker with
checkmark, read-only active-target cascade over the catalog tree, update
all subscriptions, copy HTTP export line, open main window, and quit that
states the proxy keeps running in the background. Out-of-whitelist items
(copy PAC URL) removed. Two global shortcuts (KeyboardShortcuts 3.1.0)
toggle the proxy and cycle modes through the same controller entry points
as the menu.

Presentation logic extracted to StatusMenuModel (state summary mapping,
HTTP export line, mode cycle, read-only target tree) with unit tests;
activeTargetID is now published so the menu stays live when activation
happens while the proxy is off.
2026-09-21 07:39:22 +08:00
Qiu Yuzhou e683fe99b1 feat(ng2): port semantics and conflict handling (#30)
Ports as explicit user configuration (spec #21 D8): factory defaults
1086/1087/1089, named validation errors (range + pairwise-distinct),
free-port suggestion over 32768-65535 excluding other endpoints'
configured values, best-effort occupancy probe (bind test + lsof
process name), and persisted listen settings that refuse silent port
rewrites - an unreadable store stops the runtime with a named launch
failure instead of deploying placeholder ports. PAC-port changes
surface the shared-URL invalidation notice (UI lands with #33).
Runtime bind failure keeps flowing through the #29 health gate:
launch failed, system proxy untouched.
2026-09-21 06:57:23 +08:00
Qiu Yuzhou 0ecca53a20 feat(ng2): subscription fetch, snapshot semantics and UI (#35)
SIP-008 v1 + x_shadowsocksx_ng extension parsing with flat fallback;
HTTPS/Content-Type gated fetch seam; atomic snapshot commits carrying
only the local enabled overlay; URL edit keeps identity; recursive
delete clears source, fixed group, members and credentials; subscription
cards pane and menu-bar update-all wiring.
2026-09-21 06:15:52 +08:00
Qiu Yuzhou 72f9a45a74 feat(ng2): add system proxy modes and health gate (#29) 2026-09-20 23:31:33 +08:00
Qiu Yuzhou a6825aaafa feat(ng2): diagnostics log viewer and redacted export (#34)
主窗口诊断区(spec #21 D5/D11):

- RuntimeLog 增加事件接收缝,GUI 侧接入 RuntimeEventStore 内存环形缓冲
  (容量 500),wrapper 侧不变(stderr → agent.log 收敛)
- 主窗口侧栏新增「服务器/诊断」分区切换;诊断区日志查看器双源:GUI 事件
  实时呈现 + agent.log 尾部(1s 轮询),均可复制
- DiagnosticReportBuilder 显式触发的脱敏诊断导出:只含状态、存在性、权限、
  大小/时间、数量与脱敏元数据;不读 Keychain 与契约/目录内容;原始错误
  detail 不入导出,家目录前缀改写为「~」;服务器地址与备注不进入任何输出
- 投毒夹具测试验证导出不含任何敏感类目(密码/插件参数/地址/备注/token/JSON)

Closes #34
2026-09-20 22:41:28 +08:00
Qiu Yuzhou 8578de0ba4 feat(ng2): add PAC runtime and listen scope (#28) 2026-09-20 22:26:45 +08:00
Qiu Yuzhou 6bfd3c0d35 feat(ng2): proxy runtime LaunchAgent, wrapper and sslocal lifecycle (#27)
GUI → LaunchAgent → wrapper → sslocal full chain (spec #21 D2/D5):

- ShadowsocksX-NG2Agent: Swift BundleProgram tool target embedded at
  Contents/MacOS, supervised by launchd via SMAppService agent plist
  (Contents/Library/LaunchAgents, bundle-relative ProgramArguments,
  KeepAlive={SuccessfulExit:false}). Wrapper reads the cross-process
  contract v2/sslocal-active.json, spawns sslocal -c <absolute path>
  and supervises it: SIGTERM chain stop, SIGUSR1 forward for
  server-only changes vs graceful restart on listen fingerprint
  changes, non-zero exit on unexpected child loss for KeepAlive
  replay, invalid/missing contract → clean exit with plain unlink.
- Runtime file protocol: RuntimeFileStore reuses AtomicFileWriter
  (0700 dir self-heal, 0600 temp at creation, atomic replace);
  explicit-stop cleanup unlinks contract, agent pid file and stale
  temporaries. Shared read-side validation via
  SslocalRuntimeDocument.decodeValidated so GUI and wrapper cannot
  drift. Wrapper pid file bridges SMAppService's missing pid.
- GUI: ProxyRuntimeController consumes ActivationStateMachine effects
  through pure ProxyRuntimePlan decision table (ordered actions,
  idempotent skip of identical contract); proxy toggle and launch
  failure presentation (naming endpoint:port) in the status menu;
  launch resync reconciles agent registration, wrapper liveness and
  on-disk contract; catalog commits re-expand immediately.
- Log sanitization baseline: closed RuntimeLogEvent enum plus Redactor,
  wrapper/sslocal output converged to a 0600 agent.log with RUST_LOG
  defaulting to warn.

Tests (126 total, all green): stub-sslocal driven wrapper lifecycle
(start/stop order, SIGTERM chain, crash replay, cleanup, reload
protocol), real sslocal smoke (SOCKS port binding + full SOCKS5
handshake), plan decision table, controller flows with fakes,
runtime file permissions/atomic replace, endpoint probe, redaction.

Manual release-gate items (real launchd/SMAppService): agent
registration approval flow, GUI-quit persistence, bootout behaviors.

Closes #27
2026-09-20 20:26:54 +08:00