fix(client/macos): 启动即激活 sysext + command.sock 打点

旧 sysext(on-demand/常驻)会在 app 启动前自动重连,app 走 primeExistingConnection
而非 start() → 永不提交 OSSystemExtensionRequest → bundle 内的新版 sysext 永远装不上,
运行的还是旧版(无 CommandServer)→ command.sock 不存在 → StatsClient 断流(— KB/s + 旧延迟)。

- VpnChannel.register 阶段调 activateOnLaunch():同开发者高版本静默 replace 运行中的旧扩展。
- StatsClient 连接前打点 command.sock 路径与存在性,直接暴露「旧 sysext 没起 CommandServer」。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
wangjia
2026-06-30 10:50:23 +08:00
parent 77f31c90ec
commit 4f727beb60
2 changed files with 28 additions and 0 deletions
+8
View File
@@ -47,6 +47,14 @@ final class StatsClient: NSObject {
NSLog("[pangolin/stats] LibboxNewCommandClient returned nil")
return
}
// :command.sock sysext LibboxCommandServer group
// sock CommandServer sysext()
if let base = FileManager.default
.containerURL(forSecurityApplicationGroupIdentifier: self.appGroup) {
let sock = base.appendingPathComponent("command.sock").path
let exists = FileManager.default.fileExists(atPath: sock)
NSLog("[pangolin/stats] command.sock=%@ exists=%@", sock, exists ? "YES" : "NO(sysext 未起 CommandServer/旧版)")
}
for attempt in 0..<10 {
do {
try c.connect()
+20
View File
@@ -46,6 +46,26 @@ final class VpnChannel: NSObject {
.setStreamHandler(StatsStreamHandler(owner: instance))
instance.observeStatus()
// System Extension: sysext(on-demand/)
// , app primeExistingConnection start()
// sysext (,command.sock ,
// ) register : replace,
// bundle
instance.activateOnLaunch()
}
/// / sysext(): bundle
private func activateOnLaunch() {
Task {
do {
vpnLog("launch: 主动激活 System Extension(确保运行的是 bundle 内最新版)…")
try await activateSystemExtensionIfNeeded()
vpnLog("launch: System Extension 激活/更新完成 ✓")
} catch {
let ns = error as NSError
vpnLog("launch: System Extension 激活失败 ✗ code=\(ns.code) desc=\(ns.localizedDescription)")
}
}
}
// MethodChannel