Files
ShadowsocksX-NG/ShadowsocksX-NG2/SystemProxyHelper/main.swift
T
Qiu Yuzhou c1aba5a882 fix(system-proxy): make helper XPC connection reachable and crash-free
GUI 侧 XPC 回调闭包(invalidationHandler 与 remoteObjectProxy 错误回调)在
@MainActor 方法里形成、传给非 @Sendable 的 Foundation 参数被推断为主 actor
隔离,Foundation 在 XPC 内部队列上调起时触发动态隔离断言直接崩溃;显式标注
@Sendable(nonisolated),闭包只捕获 Sendable 应答闸门。

连接系统域 LaunchDaemon 的 MachService 必须带 options: .privileged(否则只
在 per-user launchd 域查找,永远失败走错误回调);并把 resume() 提到首次远
程调用之前,超时兜底任务在应答到达后取消。

收敛/清除失败补 RuntimeLog systemProxyWriteFailed(detail:)(诊断报告白名单
按既有承诺脱敏收录),XPC/ helper 层失败原因不再只能靠崩溃报告逆向。

listener delegate 与客户端校验移入 Domain 共享编译单元(与引擎同模式),
main.swift 改为显式注入引擎;新增真实 XPC 装配层 round-trip 测试:匿名监听
器挂真实 delegate(注入假特权写入器)+ listenerEndpoint 连接,覆盖接口签
名、客户端签名校验、Data 传输与 XPC 队列应答路径,无需 launchd。
2026-09-30 13:40:16 +08:00

12 lines
542 B
Swift

import Foundation
// 特权系统代理 helper 入口(issue #71):随 app 打包、经 SMAppService.daemon
// 注册的 on-demand LaunchDaemon。launchd 以 MachServices 键按需拉起本进程,
// GUI 侧每次连接到固定 MachService 名即触发激活。
let delegate = SystemProxyHelperListenerDelegate(
engine: SystemProxyHelperEngine(perform: SystemProxyWriter.perform))
let listener = NSXPCListener(machServiceName: SystemProxyHelperIdentity.machServiceName)
listener.delegate = delegate
listener.resume()
dispatchMain()