diff --git a/Extension/Extension.entitlements b/Extension/Extension.entitlements index 95f54f9..c20576d 100644 --- a/Extension/Extension.entitlements +++ b/Extension/Extension.entitlements @@ -14,6 +14,8 @@ packet-tunnel-provider + com.apple.developer.networking.wifi-info + com.apple.developer.ubiquity-container-identifiers iCloud.io.nekohasekai.sfa diff --git a/Library/Network/CommandClient.swift b/Library/Network/CommandClient.swift index 031a5f4..5f24080 100644 --- a/Library/Network/CommandClient.swift +++ b/Library/Network/CommandClient.swift @@ -94,6 +94,9 @@ public class CommandClient: ObservableObject { func connected() { DispatchQueue.main.async { [self] in + if commandClient.connectionType == .log { + commandClient.logList = [] + } commandClient.isConnected = true } } diff --git a/Library/Network/ExtensionPlatformInterface.swift b/Library/Network/ExtensionPlatformInterface.swift index 58b6881..2095cd6 100644 --- a/Library/Network/ExtensionPlatformInterface.swift +++ b/Library/Network/ExtensionPlatformInterface.swift @@ -1,6 +1,9 @@ import Foundation import Libbox import NetworkExtension +#if canImport(CoreWLAN) + import CoreWLAN +#endif public class ExtensionPlatformInterface: NSObject, LibboxPlatformInterfaceProtocol, LibboxCommandServerHandlerProtocol { private let tunnel: ExtensionProvider @@ -172,6 +175,31 @@ public class ExtensionPlatformInterface: NSObject, LibboxPlatformInterfaceProtoc tunnel.reasserting = false } + public func readWIFIState() -> LibboxWIFIState? { + #if os(iOS) + let network = runBlocking { + await NEHotspotNetwork.fetchCurrent() + } + guard let network else { + return nil + } + return LibboxWIFIState(network.ssid, wifiBSSID: network.bssid)! + #elseif os(macOS) + guard let interface = CWWiFiClient.shared().interface() else { + return nil + } + guard let ssid = interface.ssid() else { + return nil + } + guard let bssid = interface.bssid() else { + return nil + } + return LibboxWIFIState(ssid, wifiBSSID: bssid)! + #else + return nil + #endif + } + public func serviceReload() throws { runBlocking { [self] in await tunnel.reloadService() diff --git a/Library/Network/ExtensionProvider.swift b/Library/Network/ExtensionProvider.swift index 1d14f37..bbdd29d 100644 --- a/Library/Network/ExtensionProvider.swift +++ b/Library/Network/ExtensionProvider.swift @@ -108,14 +108,15 @@ open class ExtensionProvider: NEPacketTunnelProvider { guard let service else { return } + commandServer.setService(service) do { try service.start() } catch { + commandServer.setService(nil) writeError("(packet-tunnel) error: start service: \(error.localizedDescription)") return } boxService = service - commandServer.setService(service) #if os(macOS) await SharedPreferences.startedByUser.set(true) #endif diff --git a/SystemExtension/SystemExtension.entitlements b/SystemExtension/SystemExtension.entitlements index 62d2171..54884d2 100644 --- a/SystemExtension/SystemExtension.entitlements +++ b/SystemExtension/SystemExtension.entitlements @@ -10,5 +10,7 @@ group.io.nekohasekai.sfa + com.apple.security.app-sandbox + diff --git a/sing-box.xcodeproj/project.pbxproj b/sing-box.xcodeproj/project.pbxproj index 0880a70..2bccfc4 100644 --- a/sing-box.xcodeproj/project.pbxproj +++ b/sing-box.xcodeproj/project.pbxproj @@ -2301,7 +2301,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 109; + CURRENT_PROJECT_VERSION = 114; DEAD_CODE_STRIPPING = YES; DEVELOPMENT_TEAM = Z56Z6NYZN2; ENABLE_HARDENED_RUNTIME = YES; @@ -2339,7 +2339,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 109; + CURRENT_PROJECT_VERSION = 114; DEAD_CODE_STRIPPING = YES; DEVELOPMENT_TEAM = Z56Z6NYZN2; ENABLE_HARDENED_RUNTIME = YES; @@ -2497,7 +2497,7 @@ "@executable_path/../../../../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 13.0; - MARKETING_VERSION = 1.7.0-alpha.10; + MARKETING_VERSION = 1.7.0-beta.4; PRODUCT_BUNDLE_IDENTIFIER = io.nekohasekai.sfa.system; PRODUCT_NAME = "$(inherited)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -2533,7 +2533,7 @@ "@executable_path/../../../../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 13.0; - MARKETING_VERSION = 1.7.0-alpha.10; + MARKETING_VERSION = 1.7.0-beta.4; PRODUCT_BUNDLE_IDENTIFIER = io.nekohasekai.sfa.system; PRODUCT_NAME = "$(inherited)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -2573,7 +2573,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 13.0; - MARKETING_VERSION = 1.7.0-alpha.10; + MARKETING_VERSION = 1.7.0-beta.4; PRODUCT_BUNDLE_IDENTIFIER = io.nekohasekai.sfa.independent; PRODUCT_NAME = SFM; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -2612,7 +2612,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 13.0; - MARKETING_VERSION = 1.7.0-alpha.10; + MARKETING_VERSION = 1.7.0-beta.4; PRODUCT_BUNDLE_IDENTIFIER = io.nekohasekai.sfa.independent; PRODUCT_NAME = SFM; PROVISIONING_PROFILE_SPECIFIER = "";