NE: Communicate last error to app through a shared file

Signed-off-by: Roopesh Chander <roop@roopc.net>
This commit is contained in:
Roopesh Chander
2018-12-14 02:24:53 +05:30
parent 501e412b84
commit 48552d2663
4 changed files with 84 additions and 16 deletions
@@ -17,6 +17,18 @@ extension FileManager {
return sharedFolderURL.appendingPathComponent("tunnel-log.txt")
}
static var networkExtensionLastErrorFileURL: URL? {
guard let appGroupId = Bundle.main.object(forInfoDictionaryKey: "com.wireguard.ios.app_group_id") as? String else {
os_log("Can't obtain app group id from bundle", log: OSLog.default, type: .error)
return nil
}
guard let sharedFolderURL = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: appGroupId) else {
os_log("Can't obtain shared folder URL", log: OSLog.default, type: .error)
return nil
}
return sharedFolderURL.appendingPathComponent("last-error.txt")
}
static var appLogFileURL: URL? {
guard let documentDirURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first else {
os_log("Can't obtain app documents folder URL", log: OSLog.default, type: .error)