mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-15 01:33:25 +01:00
WireGuard add extra source files
Signed-off-by: Joseph Mattello <mail@joemattiello.com>
This commit is contained in:
25
WireguardNetworkExtension/ErrorNotifier.swift
Normal file
25
WireguardNetworkExtension/ErrorNotifier.swift
Normal file
@@ -0,0 +1,25 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
|
||||
|
||||
import NetworkExtension
|
||||
|
||||
class ErrorNotifier {
|
||||
let activationAttemptId: String?
|
||||
|
||||
init(activationAttemptId: String?) {
|
||||
self.activationAttemptId = activationAttemptId
|
||||
ErrorNotifier.removeLastErrorFile()
|
||||
}
|
||||
|
||||
func notify(_ error: PacketTunnelProviderError) {
|
||||
guard let activationAttemptId = activationAttemptId, let lastErrorFilePath = FileManager.networkExtensionLastErrorFileURL?.path else { return }
|
||||
let errorMessageData = "\(activationAttemptId)\n\(error)".data(using: .utf8)
|
||||
FileManager.default.createFile(atPath: lastErrorFilePath, contents: errorMessageData, attributes: nil)
|
||||
}
|
||||
|
||||
static func removeLastErrorFile() {
|
||||
if let lastErrorFileURL = FileManager.networkExtensionLastErrorFileURL {
|
||||
_ = FileManager.deleteFile(at: lastErrorFileURL)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user