on-demand: Simplify OS-specific code for interface type selection
Previously, the enum values themselves were different for iOS and macOS. With this commit, the enum values are common, and only how they're handled is specific to iOS and macOS. Signed-off-by: Roopesh Chander <roop@roopc.net>
This commit is contained in:
committed by
Jason A. Donenfeld
parent
9795b0609a
commit
3767a12983
@@ -627,21 +627,24 @@ extension TunnelViewModel {
|
||||
switch activateOnDemandOption {
|
||||
case .none:
|
||||
return tr("tunnelOnDemandOptionOff")
|
||||
case .useOnDemandOverWiFiOnly:
|
||||
case .wiFiInterfaceOnly:
|
||||
return tr("tunnelOnDemandOptionWiFiOnly")
|
||||
#if os(iOS)
|
||||
case .useOnDemandOverWiFiOrCellular:
|
||||
return tr("tunnelOnDemandOptionWiFiOrCellular")
|
||||
case .useOnDemandOverCellularOnly:
|
||||
case .nonWiFiInterfaceOnly:
|
||||
#if os(iOS)
|
||||
return tr("tunnelOnDemandOptionCellularOnly")
|
||||
#elseif os(macOS)
|
||||
case .useOnDemandOverWiFiOrEthernet:
|
||||
return tr("tunnelOnDemandOptionWiFiOrEthernet")
|
||||
case .useOnDemandOverEthernetOnly:
|
||||
#elseif os(macOS)
|
||||
return tr("tunnelOnDemandOptionEthernetOnly")
|
||||
#else
|
||||
#error("Unimplemented")
|
||||
#endif
|
||||
#else
|
||||
#error("Unimplemented")
|
||||
#endif
|
||||
case .anyInterface:
|
||||
#if os(iOS)
|
||||
return tr("tunnelOnDemandOptionWiFiOrCellular")
|
||||
#elseif os(macOS)
|
||||
return tr("tunnelOnDemandOptionWiFiOrEthernet")
|
||||
#else
|
||||
#error("Unimplemented")
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -658,13 +661,7 @@ extension TunnelViewModel {
|
||||
}
|
||||
|
||||
static func defaultActivateOnDemandOption() -> ActivateOnDemandOption {
|
||||
#if os(iOS)
|
||||
return .useOnDemandOverWiFiOrCellular
|
||||
#elseif os(macOS)
|
||||
return .useOnDemandOverWiFiOrEthernet
|
||||
#else
|
||||
#error("Unimplemented")
|
||||
#endif
|
||||
return .anyInterface
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -44,9 +44,9 @@ class TunnelEditTableViewController: UITableViewController {
|
||||
]
|
||||
|
||||
let activateOnDemandOptions: [ActivateOnDemandOption] = [
|
||||
.useOnDemandOverWiFiOrCellular,
|
||||
.useOnDemandOverWiFiOnly,
|
||||
.useOnDemandOverCellularOnly
|
||||
.anyInterface,
|
||||
.wiFiInterfaceOnly,
|
||||
.nonWiFiInterfaceOnly
|
||||
]
|
||||
|
||||
let tunnelsManager: TunnelsManager
|
||||
|
||||
@@ -82,9 +82,9 @@ class TunnelEditViewController: NSViewController {
|
||||
|
||||
let activateOnDemandOptions: [ActivateOnDemandOption] = [
|
||||
.none,
|
||||
.useOnDemandOverWiFiOrEthernet,
|
||||
.useOnDemandOverWiFiOnly,
|
||||
.useOnDemandOverEthernetOnly
|
||||
.anyInterface,
|
||||
.wiFiInterfaceOnly,
|
||||
.nonWiFiInterfaceOnly
|
||||
]
|
||||
|
||||
let tunnelsManager: TunnelsManager
|
||||
|
||||
Reference in New Issue
Block a user