mirror of
https://github.com/passepartoutvpn/wireguard-apple.git
synced 2025-01-18 22:39:08 +00:00
Better os() directives
Signed-off-by: Roopesh Chander <roop@roopc.net>
This commit is contained in:
parent
e2b068af1a
commit
273ee04450
@ -8,8 +8,10 @@ extension FileManager {
|
|||||||
private static var sharedFolderURL: URL? {
|
private static var sharedFolderURL: URL? {
|
||||||
#if os(iOS)
|
#if os(iOS)
|
||||||
let appGroupIdInfoDictionaryKey = "com.wireguard.ios.app_group_id"
|
let appGroupIdInfoDictionaryKey = "com.wireguard.ios.app_group_id"
|
||||||
#elseif os(OSX)
|
#elseif os(macOS)
|
||||||
let appGroupIdInfoDictionaryKey = "com.wireguard.macos.app_group_id"
|
let appGroupIdInfoDictionaryKey = "com.wireguard.macos.app_group_id"
|
||||||
|
#else
|
||||||
|
#error("Unimplemented")
|
||||||
#endif
|
#endif
|
||||||
guard let appGroupId = Bundle.main.object(forInfoDictionaryKey: appGroupIdInfoDictionaryKey) as? String else {
|
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)
|
os_log("Cannot obtain app group ID from bundle", log: OSLog.default, type: .error)
|
||||||
|
@ -14,9 +14,11 @@ enum ActivateOnDemandOption {
|
|||||||
#if os(iOS)
|
#if os(iOS)
|
||||||
case useOnDemandOverWiFiOrCellular
|
case useOnDemandOverWiFiOrCellular
|
||||||
case useOnDemandOverCellularOnly
|
case useOnDemandOverCellularOnly
|
||||||
#elseif os(OSX)
|
#elseif os(macOS)
|
||||||
case useOnDemandOverWiFiOrEthernet
|
case useOnDemandOverWiFiOrEthernet
|
||||||
case useOnDemandOverEthernetOnly
|
case useOnDemandOverEthernetOnly
|
||||||
|
#else
|
||||||
|
#error("Unimplemented")
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,7 +42,7 @@ extension ActivateOnDemandSetting {
|
|||||||
connectRule.interfaceTypeMatch = .cellular
|
connectRule.interfaceTypeMatch = .cellular
|
||||||
disconnectRule.interfaceTypeMatch = .wiFi
|
disconnectRule.interfaceTypeMatch = .wiFi
|
||||||
rules = [connectRule, disconnectRule]
|
rules = [connectRule, disconnectRule]
|
||||||
#elseif os(OSX)
|
#elseif os(macOS)
|
||||||
case .useOnDemandOverWiFiOrEthernet:
|
case .useOnDemandOverWiFiOrEthernet:
|
||||||
rules = [connectRule]
|
rules = [connectRule]
|
||||||
case .useOnDemandOverWiFiOnly:
|
case .useOnDemandOverWiFiOnly:
|
||||||
@ -51,6 +53,8 @@ extension ActivateOnDemandSetting {
|
|||||||
connectRule.interfaceTypeMatch = .ethernet
|
connectRule.interfaceTypeMatch = .ethernet
|
||||||
disconnectRule.interfaceTypeMatch = .wiFi
|
disconnectRule.interfaceTypeMatch = .wiFi
|
||||||
rules = [connectRule, disconnectRule]
|
rules = [connectRule, disconnectRule]
|
||||||
|
#else
|
||||||
|
#error("Unimplemented")
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
tunnelProviderManager.onDemandRules = rules
|
tunnelProviderManager.onDemandRules = rules
|
||||||
@ -62,10 +66,12 @@ extension ActivateOnDemandSetting {
|
|||||||
let otherInterfaceType: NEOnDemandRuleInterfaceType = .cellular
|
let otherInterfaceType: NEOnDemandRuleInterfaceType = .cellular
|
||||||
let useWiFiOrOtherOption: ActivateOnDemandOption = .useOnDemandOverWiFiOrCellular
|
let useWiFiOrOtherOption: ActivateOnDemandOption = .useOnDemandOverWiFiOrCellular
|
||||||
let useOtherOnlyOption: ActivateOnDemandOption = .useOnDemandOverCellularOnly
|
let useOtherOnlyOption: ActivateOnDemandOption = .useOnDemandOverCellularOnly
|
||||||
#elseif os(OSX)
|
#elseif os(macOS)
|
||||||
let otherInterfaceType: NEOnDemandRuleInterfaceType = .ethernet
|
let otherInterfaceType: NEOnDemandRuleInterfaceType = .ethernet
|
||||||
let useWiFiOrOtherOption: ActivateOnDemandOption = .useOnDemandOverWiFiOrEthernet
|
let useWiFiOrOtherOption: ActivateOnDemandOption = .useOnDemandOverWiFiOrEthernet
|
||||||
let useOtherOnlyOption: ActivateOnDemandOption = .useOnDemandOverEthernetOnly
|
let useOtherOnlyOption: ActivateOnDemandOption = .useOnDemandOverEthernetOnly
|
||||||
|
#else
|
||||||
|
#error("Unimplemented")
|
||||||
#endif
|
#endif
|
||||||
let activateOnDemandOption: ActivateOnDemandOption
|
let activateOnDemandOption: ActivateOnDemandOption
|
||||||
switch rules.count {
|
switch rules.count {
|
||||||
|
@ -461,11 +461,13 @@ extension TunnelViewModel {
|
|||||||
return tr("tunnelOnDemandOptionWiFiOrCellular")
|
return tr("tunnelOnDemandOptionWiFiOrCellular")
|
||||||
case .useOnDemandOverCellularOnly:
|
case .useOnDemandOverCellularOnly:
|
||||||
return tr("tunnelOnDemandOptionCellularOnly")
|
return tr("tunnelOnDemandOptionCellularOnly")
|
||||||
#elseif os(OSX)
|
#elseif os(macOS)
|
||||||
case .useOnDemandOverWiFiOrEthernet:
|
case .useOnDemandOverWiFiOrEthernet:
|
||||||
return tr("tunnelOnDemandOptionWiFiOrEthernet")
|
return tr("tunnelOnDemandOptionWiFiOrEthernet")
|
||||||
case .useOnDemandOverEthernetOnly:
|
case .useOnDemandOverEthernetOnly:
|
||||||
return tr("tunnelOnDemandOptionEthernetOnly")
|
return tr("tunnelOnDemandOptionEthernetOnly")
|
||||||
|
#else
|
||||||
|
#error("Unimplemented")
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -485,8 +487,10 @@ extension TunnelViewModel {
|
|||||||
static func defaultActivateOnDemandOption() -> ActivateOnDemandOption {
|
static func defaultActivateOnDemandOption() -> ActivateOnDemandOption {
|
||||||
#if os(iOS)
|
#if os(iOS)
|
||||||
return .useOnDemandOverWiFiOrCellular
|
return .useOnDemandOverWiFiOrCellular
|
||||||
#elseif os(OSX)
|
#elseif os(macOS)
|
||||||
return .useOnDemandOverWiFiOrEthernet
|
return .useOnDemandOverWiFiOrEthernet
|
||||||
|
#else
|
||||||
|
#error("Unimplemented")
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -81,8 +81,10 @@ class PacketTunnelSettingsGenerator {
|
|||||||
if mtu == 0 {
|
if mtu == 0 {
|
||||||
#if os(iOS)
|
#if os(iOS)
|
||||||
networkSettings.mtu = NSNumber(value: 1280)
|
networkSettings.mtu = NSNumber(value: 1280)
|
||||||
#elseif os(OSX)
|
#elseif os(macOS)
|
||||||
networkSettings.tunnelOverheadBytes = 80
|
networkSettings.tunnelOverheadBytes = 80
|
||||||
|
#else
|
||||||
|
#error("Unimplemented")
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
networkSettings.mtu = NSNumber(value: mtu)
|
networkSettings.mtu = NSNumber(value: mtu)
|
||||||
|
Loading…
Reference in New Issue
Block a user