aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard
diff options
context:
space:
mode:
authorRoopesh Chander <roop@roopc.net>2019-01-22 04:06:27 +0530
committerRoopesh Chander <roop@roopc.net>2019-01-22 04:06:37 +0530
commit273ee04450b776bb5456c75ef17caa2e9e5ed2e7 (patch)
tree722f2ed10ef9357a456561bd9552fe69d7316671 /WireGuard
parentmacOS: Tunnel edit: actually clean up error handling (diff)
downloadwireguard-apple-273ee04450b776bb5456c75ef17caa2e9e5ed2e7.tar.xz
wireguard-apple-273ee04450b776bb5456c75ef17caa2e9e5ed2e7.zip
Better os() directives
Signed-off-by: Roopesh Chander <roop@roopc.net>
Diffstat (limited to 'WireGuard')
-rw-r--r--WireGuard/Shared/FileManager+Extension.swift4
-rw-r--r--WireGuard/WireGuard/Tunnel/ActivateOnDemandSetting.swift12
-rw-r--r--WireGuard/WireGuard/UI/TunnelViewModel.swift8
-rw-r--r--WireGuard/WireGuardNetworkExtension/PacketTunnelSettingsGenerator.swift4
4 files changed, 21 insertions, 7 deletions
diff --git a/WireGuard/Shared/FileManager+Extension.swift b/WireGuard/Shared/FileManager+Extension.swift
index d98cd0a9..21556835 100644
--- a/WireGuard/Shared/FileManager+Extension.swift
+++ b/WireGuard/Shared/FileManager+Extension.swift
@@ -8,8 +8,10 @@ extension FileManager {
private static var sharedFolderURL: URL? {
#if os(iOS)
let appGroupIdInfoDictionaryKey = "com.wireguard.ios.app_group_id"
- #elseif os(OSX)
+ #elseif os(macOS)
let appGroupIdInfoDictionaryKey = "com.wireguard.macos.app_group_id"
+ #else
+ #error("Unimplemented")
#endif
guard let appGroupId = Bundle.main.object(forInfoDictionaryKey: appGroupIdInfoDictionaryKey) as? String else {
os_log("Cannot obtain app group ID from bundle", log: OSLog.default, type: .error)
diff --git a/WireGuard/WireGuard/Tunnel/ActivateOnDemandSetting.swift b/WireGuard/WireGuard/Tunnel/ActivateOnDemandSetting.swift
index c89cce37..38359da4 100644
--- a/WireGuard/WireGuard/Tunnel/ActivateOnDemandSetting.swift
+++ b/WireGuard/WireGuard/Tunnel/ActivateOnDemandSetting.swift
@@ -14,9 +14,11 @@ enum ActivateOnDemandOption {
#if os(iOS)
case useOnDemandOverWiFiOrCellular
case useOnDemandOverCellularOnly
- #elseif os(OSX)
+ #elseif os(macOS)
case useOnDemandOverWiFiOrEthernet
case useOnDemandOverEthernetOnly
+ #else
+ #error("Unimplemented")
#endif
}
@@ -40,7 +42,7 @@ extension ActivateOnDemandSetting {
connectRule.interfaceTypeMatch = .cellular
disconnectRule.interfaceTypeMatch = .wiFi
rules = [connectRule, disconnectRule]
- #elseif os(OSX)
+ #elseif os(macOS)
case .useOnDemandOverWiFiOrEthernet:
rules = [connectRule]
case .useOnDemandOverWiFiOnly:
@@ -51,6 +53,8 @@ extension ActivateOnDemandSetting {
connectRule.interfaceTypeMatch = .ethernet
disconnectRule.interfaceTypeMatch = .wiFi
rules = [connectRule, disconnectRule]
+ #else
+ #error("Unimplemented")
#endif
}
tunnelProviderManager.onDemandRules = rules
@@ -62,10 +66,12 @@ extension ActivateOnDemandSetting {
let otherInterfaceType: NEOnDemandRuleInterfaceType = .cellular
let useWiFiOrOtherOption: ActivateOnDemandOption = .useOnDemandOverWiFiOrCellular
let useOtherOnlyOption: ActivateOnDemandOption = .useOnDemandOverCellularOnly
- #elseif os(OSX)
+ #elseif os(macOS)
let otherInterfaceType: NEOnDemandRuleInterfaceType = .ethernet
let useWiFiOrOtherOption: ActivateOnDemandOption = .useOnDemandOverWiFiOrEthernet
let useOtherOnlyOption: ActivateOnDemandOption = .useOnDemandOverEthernetOnly
+ #else
+ #error("Unimplemented")
#endif
let activateOnDemandOption: ActivateOnDemandOption
switch rules.count {
diff --git a/WireGuard/WireGuard/UI/TunnelViewModel.swift b/WireGuard/WireGuard/UI/TunnelViewModel.swift
index 50d97c39..07d1bac1 100644
--- a/WireGuard/WireGuard/UI/TunnelViewModel.swift
+++ b/WireGuard/WireGuard/UI/TunnelViewModel.swift
@@ -461,11 +461,13 @@ extension TunnelViewModel {
return tr("tunnelOnDemandOptionWiFiOrCellular")
case .useOnDemandOverCellularOnly:
return tr("tunnelOnDemandOptionCellularOnly")
- #elseif os(OSX)
+ #elseif os(macOS)
case .useOnDemandOverWiFiOrEthernet:
return tr("tunnelOnDemandOptionWiFiOrEthernet")
case .useOnDemandOverEthernetOnly:
return tr("tunnelOnDemandOptionEthernetOnly")
+ #else
+ #error("Unimplemented")
#endif
}
}
@@ -485,8 +487,10 @@ extension TunnelViewModel {
static func defaultActivateOnDemandOption() -> ActivateOnDemandOption {
#if os(iOS)
return .useOnDemandOverWiFiOrCellular
- #elseif os(OSX)
+ #elseif os(macOS)
return .useOnDemandOverWiFiOrEthernet
+ #else
+ #error("Unimplemented")
#endif
}
}
diff --git a/WireGuard/WireGuardNetworkExtension/PacketTunnelSettingsGenerator.swift b/WireGuard/WireGuardNetworkExtension/PacketTunnelSettingsGenerator.swift
index a1f90f1d..02588c33 100644
--- a/WireGuard/WireGuardNetworkExtension/PacketTunnelSettingsGenerator.swift
+++ b/WireGuard/WireGuardNetworkExtension/PacketTunnelSettingsGenerator.swift
@@ -81,8 +81,10 @@ class PacketTunnelSettingsGenerator {
if mtu == 0 {
#if os(iOS)
networkSettings.mtu = NSNumber(value: 1280)
- #elseif os(OSX)
+ #elseif os(macOS)
networkSettings.tunnelOverheadBytes = 80
+ #else
+ #error("Unimplemented")
#endif
} else {
networkSettings.mtu = NSNumber(value: mtu)