Add read WIFI state support
This commit is contained in:
@@ -14,6 +14,8 @@
|
||||
<array>
|
||||
<string>packet-tunnel-provider</string>
|
||||
</array>
|
||||
<key>com.apple.developer.networking.wifi-info</key>
|
||||
<true/>
|
||||
<key>com.apple.developer.ubiquity-container-identifiers</key>
|
||||
<array>
|
||||
<string>iCloud.io.nekohasekai.sfa</string>
|
||||
|
||||
@@ -94,6 +94,9 @@ public class CommandClient: ObservableObject {
|
||||
|
||||
func connected() {
|
||||
DispatchQueue.main.async { [self] in
|
||||
if commandClient.connectionType == .log {
|
||||
commandClient.logList = []
|
||||
}
|
||||
commandClient.isConnected = true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -10,5 +10,7 @@
|
||||
<array>
|
||||
<string>group.io.nekohasekai.sfa</string>
|
||||
</array>
|
||||
<key>com.apple.security.app-sandbox</key>
|
||||
<false/>
|
||||
</dict>
|
||||
</plist>
|
||||
|
||||
@@ -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 = "";
|
||||
|
||||
Reference in New Issue
Block a user