Add FDA request dialog

This commit is contained in:
世界
2024-10-05 10:03:59 +08:00
parent 41ed30a5fa
commit 88ee9d5097
7 changed files with 92 additions and 9 deletions
@@ -1,5 +1,7 @@
import Libbox
import Library
import NetworkExtension
import System
class PacketTunnelProvider: ExtensionProvider {
override func startTunnel(options: [String: NSObject]?) async throws {
@@ -10,6 +12,19 @@ class PacketTunnelProvider: ExtensionProvider {
let username = usernameObject as! NSString
FilePath.sharedDirectory = URL(filePath: "/Users/\(username)/Library/Group Containers/\(FilePath.groupName)")
FilePath.iCloudDirectory = URL(filePath: "/Users/\(username)/Library/Mobile Documents/iCloud~\(FilePath.packageName.replacingOccurrences(of: ".", with: "~"))").appendingPathComponent("Documents", isDirectory: true)
let databasePath = FilePath.sharedDirectory.appendingPathComponent("settings.db").relativePath
if !FileManager.default.isReadableFile(atPath: databasePath) {
do {
let fd = try FileDescriptor.open(databasePath, .readOnly)
try! fd.close()
NSLog("Can access \(databasePath)")
} catch {
NSLog("Can't access \(databasePath): \(error.localizedDescription)")
}
try await Task.sleep(nanoseconds: NSEC_PER_MSEC * 100)
throw FullDiskAccessPermissionRequired.error
}
self.username = String(username)
try await super.startTunnel(options: options)
}