From 98386ded25131534a3e74bd2408fbcb90741a3eb Mon Sep 17 00:00:00 2001 From: anlicheng <244108715@qq.com> Date: Wed, 15 Apr 2026 10:37:45 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E9=80=9A=E7=9F=A5=E4=B8=AD=E5=BF=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Tun/PacketTunnelProvider.swift | 2 +- Tun/Punchnet/SDLTunnelAppNotifier.swift | 4 ++-- ...NotificationCenter.swift => SDLNotificationCenter.swift} | 6 +++--- punchnet/punchnetApp.swift | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) rename punchnet/Core/{DarwinNotificationCenter.swift => SDLNotificationCenter.swift} (94%) diff --git a/Tun/PacketTunnelProvider.swift b/Tun/PacketTunnelProvider.swift index 0c08dc3..c554528 100644 --- a/Tun/PacketTunnelProvider.swift +++ b/Tun/PacketTunnelProvider.swift @@ -22,7 +22,7 @@ class PacketTunnelProvider: NEPacketTunnelProvider { let msg = shared?.string(forKey: "test_msg") SDLLogger.log("NE read message: \(msg ?? "failed")", for: .debug) - DarwinNotificationCenter.shared.post(.vpnStatusChanged) + SDLNotificationCenter.shared.post(.vpnStatusChanged) // 如果当前在运行状态,不允许重复请求 guard self.contextActor == nil else { diff --git a/Tun/Punchnet/SDLTunnelAppNotifier.swift b/Tun/Punchnet/SDLTunnelAppNotifier.swift index 60a0b1f..6ab56fa 100644 --- a/Tun/Punchnet/SDLTunnelAppNotifier.swift +++ b/Tun/Punchnet/SDLTunnelAppNotifier.swift @@ -56,7 +56,7 @@ final class SDLTunnelAppNotifier { shared.set(data, forKey: self.eventKey) shared.synchronize() - DarwinNotificationCenter.shared.post(.tunnelEventChanged) + SDLNotificationCenter.shared.post(.tunnelEventChanged) } func clear() { @@ -66,6 +66,6 @@ final class SDLTunnelAppNotifier { shared.removeObject(forKey: self.eventKey) shared.synchronize() - DarwinNotificationCenter.shared.post(.tunnelEventChanged) + SDLNotificationCenter.shared.post(.tunnelEventChanged) } } diff --git a/punchnet/Core/DarwinNotificationCenter.swift b/punchnet/Core/SDLNotificationCenter.swift similarity index 94% rename from punchnet/Core/DarwinNotificationCenter.swift rename to punchnet/Core/SDLNotificationCenter.swift index 11b01c6..a94cda7 100644 --- a/punchnet/Core/DarwinNotificationCenter.swift +++ b/punchnet/Core/SDLNotificationCenter.swift @@ -23,8 +23,8 @@ extension DarwinNotificationName { // MARK: - Manager -public final class DarwinNotificationCenter { - public static let shared = DarwinNotificationCenter() +public final class SDLNotificationCenter { + public static let shared = SDLNotificationCenter() private let center = CFNotificationCenterGetDarwinNotifyCenter() @@ -50,7 +50,7 @@ public final class DarwinNotificationCenter { return } - let instance = Unmanaged + let instance = Unmanaged .fromOpaque(observer) .takeUnretainedValue() diff --git a/punchnet/punchnetApp.swift b/punchnet/punchnetApp.swift index 641949e..64ef2c7 100644 --- a/punchnet/punchnetApp.swift +++ b/punchnet/punchnetApp.swift @@ -93,7 +93,7 @@ class AppDelegate: NSObject, NSApplicationDelegate { shared?.set("App says hello", forKey: "test_msg") shared?.synchronize() - DarwinNotificationCenter.shared.addObserver(for: .vpnStatusChanged) { name in + SDLNotificationCenter.shared.addObserver(for: .vpnStatusChanged) { name in NSLog("DarwinNotificationCenter get message: \(name)") } }