refactor: Fix macOS standalone application

This commit is contained in:
世界
2026-01-05 01:21:24 +08:00
parent ef1c924c64
commit 59317f3c79
66 changed files with 2799 additions and 585 deletions
+1 -27
View File
@@ -1,30 +1,4 @@
import Libbox
import Library
import NetworkExtension
import System
class PacketTunnelProvider: ExtensionProvider {
override func startTunnel(options: [String: NSObject]?) async throws {
guard let usernameObject = options?["username"] else {
throw ExtensionStartupError("missing start options")
}
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)
}
}
class PacketTunnelProvider: ExtensionProvider {}
+2 -2
View File
@@ -8,11 +8,11 @@
<array>
<string>packet-tunnel-provider-systemextension</string>
</array>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.application-groups</key>
<array>
<string>$(TeamIdentifierPrefix)$(BASE_PACKAGE_IDENTIFIER)</string>
</array>
<key>com.apple.security.app-sandbox</key>
<false/>
</dict>
</plist>