Fix read WIFI information on macOS app store version
This commit is contained in:
@@ -30,5 +30,7 @@
|
|||||||
<true/>
|
<true/>
|
||||||
<key>com.apple.security.network.server</key>
|
<key>com.apple.security.network.server</key>
|
||||||
<true/>
|
<true/>
|
||||||
|
<key>com.apple.security.personal-information.location</key>
|
||||||
|
<true/>
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import Foundation
|
|||||||
import Libbox
|
import Libbox
|
||||||
import NetworkExtension
|
import NetworkExtension
|
||||||
import UserNotifications
|
import UserNotifications
|
||||||
#if canImport(CoreWLAN)
|
#if os(macOS)
|
||||||
import CoreWLAN
|
import CoreWLAN
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ import NetworkExtension
|
|||||||
#if os(iOS)
|
#if os(iOS)
|
||||||
import WidgetKit
|
import WidgetKit
|
||||||
#endif
|
#endif
|
||||||
|
#if os(macOS)
|
||||||
|
import CoreLocation
|
||||||
|
#endif
|
||||||
|
|
||||||
open class ExtensionProvider: NEPacketTunnelProvider {
|
open class ExtensionProvider: NEPacketTunnelProvider {
|
||||||
public var username: String? = nil
|
public var username: String? = nil
|
||||||
@@ -73,7 +76,7 @@ open class ExtensionProvider: NEPacketTunnelProvider {
|
|||||||
writeMessage(message)
|
writeMessage(message)
|
||||||
var error: NSError?
|
var error: NSError?
|
||||||
LibboxWriteServiceError(message, &error)
|
LibboxWriteServiceError(message, &error)
|
||||||
cancelTunnelWithError(NSError(domain: message, code: 0))
|
cancelTunnelWithError(nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
private func startService() async {
|
private func startService() async {
|
||||||
@@ -114,9 +117,41 @@ open class ExtensionProvider: NEPacketTunnelProvider {
|
|||||||
boxService = service
|
boxService = service
|
||||||
#if os(macOS)
|
#if os(macOS)
|
||||||
await SharedPreferences.startedByUser.set(true)
|
await SharedPreferences.startedByUser.set(true)
|
||||||
|
if service.needWIFIState() {
|
||||||
|
if !Variant.useSystemExtension {
|
||||||
|
locationManager = CLLocationManager()
|
||||||
|
locationDelegate = stubLocationDelegate(boxService)
|
||||||
|
locationManager?.delegate = locationDelegate
|
||||||
|
locationManager?.requestLocation()
|
||||||
|
} else {
|
||||||
|
commandServer.writeMessage("(packet-tunnel) WIFI SSID and BSSID information is not currently available in the standalone version of SFM. We are working on resolving this issue.")
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if os(macOS)
|
||||||
|
|
||||||
|
private var locationManager: CLLocationManager?
|
||||||
|
private var locationDelegate: stubLocationDelegate?
|
||||||
|
|
||||||
|
class stubLocationDelegate: NSObject, CLLocationManagerDelegate {
|
||||||
|
private unowned let boxService: LibboxBoxService
|
||||||
|
init(_ boxService: LibboxBoxService) {
|
||||||
|
self.boxService = boxService
|
||||||
|
}
|
||||||
|
|
||||||
|
func locationManagerDidChangeAuthorization(_: CLLocationManager) {
|
||||||
|
boxService.updateWIFIState()
|
||||||
|
}
|
||||||
|
|
||||||
|
func locationManager(_: CLLocationManager, didUpdateLocations _: [CLLocation]) {}
|
||||||
|
|
||||||
|
func locationManager(_: CLLocationManager, didFailWithError _: Error) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
private func stopService() {
|
private func stopService() {
|
||||||
if let service = boxService {
|
if let service = boxService {
|
||||||
do {
|
do {
|
||||||
|
|||||||
@@ -105,5 +105,13 @@
|
|||||||
</array>
|
</array>
|
||||||
<key>CFBundleDevelopmentRegion</key>
|
<key>CFBundleDevelopmentRegion</key>
|
||||||
<string>en</string>
|
<string>en</string>
|
||||||
|
<key>NSLocationAlwaysUsageDescription</key>
|
||||||
|
<string>sing-box uses the Location permission to provide users with routing based on WIFI SSID and BSSID rules, without reading your location.</string>
|
||||||
|
<key>NSLocationUsageDescription</key>
|
||||||
|
<string>sing-box uses the Location permission to provide users with routing based on WIFI SSID and BSSID rules, without reading your location.</string>
|
||||||
|
<key>NSLocationWhenInUseUsageDescription</key>
|
||||||
|
<string>sing-box uses the Location permission to provide users with routing based on WIFI SSID and BSSID rules, without reading your location.</string>
|
||||||
|
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
|
||||||
|
<string>sing-box uses the Location permission to provide users with routing based on WIFI SSID and BSSID rules, without reading your location.</string>
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
|
|||||||
Reference in New Issue
Block a user