aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@mullvad.net>2020-12-02 13:53:16 +0100
committerAndrej Mihajlov <and@mullvad.net>2020-12-03 13:22:52 +0100
commit2e356d3d8f3ea4af13a2d69db2eefefd10b9c9bd (patch)
treef5334f0e1af2af412701ad1996887cfba4abbcc8
parentWireGuardKit: Remove isStarted: bool from WireGuardAdapter (diff)
downloadwireguard-apple-2e356d3d8f3ea4af13a2d69db2eefefd10b9c9bd.tar.xz
wireguard-apple-2e356d3d8f3ea4af13a2d69db2eefefd10b9c9bd.zip
WireGuardKit: Remove handleLogLine from WireGuardAdapter
Signed-off-by: Andrej Mihajlov <and@mullvad.net>
-rw-r--r--WireGuardKit/Sources/WireGuardKit/WireGuardAdapter.swift31
1 files changed, 9 insertions, 22 deletions
diff --git a/WireGuardKit/Sources/WireGuardKit/WireGuardAdapter.swift b/WireGuardKit/Sources/WireGuardKit/WireGuardAdapter.swift
index 12f7d23..c5a6e2c 100644
--- a/WireGuardKit/Sources/WireGuardKit/WireGuardAdapter.swift
+++ b/WireGuardKit/Sources/WireGuardKit/WireGuardAdapter.swift
@@ -239,7 +239,7 @@ public class WireGuardAdapter {
let swiftString = String(cString: message).trimmingCharacters(in: .newlines)
let tunnelLogLevel = WireGuardLogLevel(rawValue: logLevel) ?? .debug
- unretainedSelf.handleLogLine(level: tunnelLogLevel, message: swiftString)
+ unretainedSelf.logHandler(tunnelLogLevel, swiftString)
}
}
@@ -316,33 +316,20 @@ public class WireGuardAdapter {
return resolvedEndpoints
}
- /// Private helper to pass the logs coming from WireGuard to
- /// - Parameters:
- /// - level: log level
- /// - message: message
- private func handleLogLine(level: WireGuardLogLevel, message: String) {
- workQueue.async {
- self.logHandler?(level, message)
- }
- }
-
/// Helper method used by network path monitor.
/// - Parameter path: new network path
private func didReceivePathUpdate(path: Network.NWPath) {
+ guard let handle = self.wireguardHandle else { return }
- if let handle = self.wireguardHandle {
- self.handleLogLine(level: .debug, message: "Network change detected with \(path.status) route and interface order \(path.availableInterfaces)")
+ self.logHandler(.debug, "Network change detected with \(path.status) route and interface order \(path.availableInterfaces)")
- #if os(iOS)
- if let settingsGenerator = self.settingsGenerator {
- wgSetConfig(handle, settingsGenerator.endpointUapiConfiguration())
- }
-
- // TODO: dynamically turn on or off WireGuard backend when entering airplane mode
- #endif
-
- wgBumpSockets(handle)
+ #if os(iOS)
+ if let settingsGenerator = self.settingsGenerator {
+ wgSetConfig(handle, settingsGenerator.endpointUapiConfiguration())
}
+ #endif
+
+ wgBumpSockets(handle)
}
}