Add read WIFI state support
This commit is contained in:
@@ -14,6 +14,8 @@
|
|||||||
<array>
|
<array>
|
||||||
<string>packet-tunnel-provider</string>
|
<string>packet-tunnel-provider</string>
|
||||||
</array>
|
</array>
|
||||||
|
<key>com.apple.developer.networking.wifi-info</key>
|
||||||
|
<true/>
|
||||||
<key>com.apple.developer.ubiquity-container-identifiers</key>
|
<key>com.apple.developer.ubiquity-container-identifiers</key>
|
||||||
<array>
|
<array>
|
||||||
<string>iCloud.io.nekohasekai.sfa</string>
|
<string>iCloud.io.nekohasekai.sfa</string>
|
||||||
|
|||||||
@@ -94,6 +94,9 @@ public class CommandClient: ObservableObject {
|
|||||||
|
|
||||||
func connected() {
|
func connected() {
|
||||||
DispatchQueue.main.async { [self] in
|
DispatchQueue.main.async { [self] in
|
||||||
|
if commandClient.connectionType == .log {
|
||||||
|
commandClient.logList = []
|
||||||
|
}
|
||||||
commandClient.isConnected = true
|
commandClient.isConnected = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import Libbox
|
import Libbox
|
||||||
import NetworkExtension
|
import NetworkExtension
|
||||||
|
#if canImport(CoreWLAN)
|
||||||
|
import CoreWLAN
|
||||||
|
#endif
|
||||||
|
|
||||||
public class ExtensionPlatformInterface: NSObject, LibboxPlatformInterfaceProtocol, LibboxCommandServerHandlerProtocol {
|
public class ExtensionPlatformInterface: NSObject, LibboxPlatformInterfaceProtocol, LibboxCommandServerHandlerProtocol {
|
||||||
private let tunnel: ExtensionProvider
|
private let tunnel: ExtensionProvider
|
||||||
@@ -172,6 +175,31 @@ public class ExtensionPlatformInterface: NSObject, LibboxPlatformInterfaceProtoc
|
|||||||
tunnel.reasserting = false
|
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 {
|
public func serviceReload() throws {
|
||||||
runBlocking { [self] in
|
runBlocking { [self] in
|
||||||
await tunnel.reloadService()
|
await tunnel.reloadService()
|
||||||
|
|||||||
@@ -108,14 +108,15 @@ open class ExtensionProvider: NEPacketTunnelProvider {
|
|||||||
guard let service else {
|
guard let service else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
commandServer.setService(service)
|
||||||
do {
|
do {
|
||||||
try service.start()
|
try service.start()
|
||||||
} catch {
|
} catch {
|
||||||
|
commandServer.setService(nil)
|
||||||
writeError("(packet-tunnel) error: start service: \(error.localizedDescription)")
|
writeError("(packet-tunnel) error: start service: \(error.localizedDescription)")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
boxService = service
|
boxService = service
|
||||||
commandServer.setService(service)
|
|
||||||
#if os(macOS)
|
#if os(macOS)
|
||||||
await SharedPreferences.startedByUser.set(true)
|
await SharedPreferences.startedByUser.set(true)
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -10,5 +10,7 @@
|
|||||||
<array>
|
<array>
|
||||||
<string>group.io.nekohasekai.sfa</string>
|
<string>group.io.nekohasekai.sfa</string>
|
||||||
</array>
|
</array>
|
||||||
|
<key>com.apple.security.app-sandbox</key>
|
||||||
|
<false/>
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
|
|||||||
@@ -2301,7 +2301,7 @@
|
|||||||
CODE_SIGN_IDENTITY = "Apple Development";
|
CODE_SIGN_IDENTITY = "Apple Development";
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
COMBINE_HIDPI_IMAGES = YES;
|
COMBINE_HIDPI_IMAGES = YES;
|
||||||
CURRENT_PROJECT_VERSION = 109;
|
CURRENT_PROJECT_VERSION = 114;
|
||||||
DEAD_CODE_STRIPPING = YES;
|
DEAD_CODE_STRIPPING = YES;
|
||||||
DEVELOPMENT_TEAM = Z56Z6NYZN2;
|
DEVELOPMENT_TEAM = Z56Z6NYZN2;
|
||||||
ENABLE_HARDENED_RUNTIME = YES;
|
ENABLE_HARDENED_RUNTIME = YES;
|
||||||
@@ -2339,7 +2339,7 @@
|
|||||||
CODE_SIGN_IDENTITY = "Apple Development";
|
CODE_SIGN_IDENTITY = "Apple Development";
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
COMBINE_HIDPI_IMAGES = YES;
|
COMBINE_HIDPI_IMAGES = YES;
|
||||||
CURRENT_PROJECT_VERSION = 109;
|
CURRENT_PROJECT_VERSION = 114;
|
||||||
DEAD_CODE_STRIPPING = YES;
|
DEAD_CODE_STRIPPING = YES;
|
||||||
DEVELOPMENT_TEAM = Z56Z6NYZN2;
|
DEVELOPMENT_TEAM = Z56Z6NYZN2;
|
||||||
ENABLE_HARDENED_RUNTIME = YES;
|
ENABLE_HARDENED_RUNTIME = YES;
|
||||||
@@ -2497,7 +2497,7 @@
|
|||||||
"@executable_path/../../../../Frameworks",
|
"@executable_path/../../../../Frameworks",
|
||||||
);
|
);
|
||||||
MACOSX_DEPLOYMENT_TARGET = 13.0;
|
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_BUNDLE_IDENTIFIER = io.nekohasekai.sfa.system;
|
||||||
PRODUCT_NAME = "$(inherited)";
|
PRODUCT_NAME = "$(inherited)";
|
||||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||||
@@ -2533,7 +2533,7 @@
|
|||||||
"@executable_path/../../../../Frameworks",
|
"@executable_path/../../../../Frameworks",
|
||||||
);
|
);
|
||||||
MACOSX_DEPLOYMENT_TARGET = 13.0;
|
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_BUNDLE_IDENTIFIER = io.nekohasekai.sfa.system;
|
||||||
PRODUCT_NAME = "$(inherited)";
|
PRODUCT_NAME = "$(inherited)";
|
||||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||||
@@ -2573,7 +2573,7 @@
|
|||||||
"@executable_path/../Frameworks",
|
"@executable_path/../Frameworks",
|
||||||
);
|
);
|
||||||
MACOSX_DEPLOYMENT_TARGET = 13.0;
|
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_BUNDLE_IDENTIFIER = io.nekohasekai.sfa.independent;
|
||||||
PRODUCT_NAME = SFM;
|
PRODUCT_NAME = SFM;
|
||||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||||
@@ -2612,7 +2612,7 @@
|
|||||||
"@executable_path/../Frameworks",
|
"@executable_path/../Frameworks",
|
||||||
);
|
);
|
||||||
MACOSX_DEPLOYMENT_TARGET = 13.0;
|
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_BUNDLE_IDENTIFIER = io.nekohasekai.sfa.independent;
|
||||||
PRODUCT_NAME = SFM;
|
PRODUCT_NAME = SFM;
|
||||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||||
|
|||||||
Reference in New Issue
Block a user