refactor: CommandClient & Connections

This commit is contained in:
世界
2026-01-16 20:08:33 +08:00
parent c479921a4f
commit 12c8bff2d4
6 changed files with 74 additions and 37 deletions
+13 -1
View File
@@ -171,7 +171,16 @@ open class ExtensionProvider: NEPacketTunnelProvider {
#endif
writeMessage("(packet-tunnel): Here I stand")
try await startService()
do {
try await startService()
} catch {
#if os(macOS)
if Variant.useSystemExtension {
xpcService.markServiceNotReady(error)
}
#endif
throw error
}
#if os(macOS)
if Variant.useSystemExtension {
xpcService.markServiceReady()
@@ -251,6 +260,9 @@ open class ExtensionProvider: NEPacketTunnelProvider {
}
#if os(macOS)
if Variant.useSystemExtension {
xpcService.markServiceNotReady(NSError(domain: "CommandXPC", code: -1, userInfo: [
NSLocalizedDescriptionKey: "Command server stopped",
]))
xpcListener.invalidate()
xpcListener = nil
xpcService.commandServer = nil