Tunnel view model: VPN-on-demand stuff shouldn't be part of the tunnel model
Signed-off-by: Roopesh Chander <roop@roopc.net>
This commit is contained in:
parent
cc122d7463
commit
f1b8de7312
|
@ -372,7 +372,6 @@ class TunnelViewModel {
|
||||||
|
|
||||||
var interfaceData: InterfaceData
|
var interfaceData: InterfaceData
|
||||||
var peersData: [PeerData]
|
var peersData: [PeerData]
|
||||||
var activationType: ActivationType
|
|
||||||
|
|
||||||
init(tunnelConfiguration: TunnelConfiguration?) {
|
init(tunnelConfiguration: TunnelConfiguration?) {
|
||||||
let interfaceData: InterfaceData = InterfaceData()
|
let interfaceData: InterfaceData = InterfaceData()
|
||||||
|
@ -392,20 +391,6 @@ class TunnelViewModel {
|
||||||
}
|
}
|
||||||
self.interfaceData = interfaceData
|
self.interfaceData = interfaceData
|
||||||
self.peersData = peersData
|
self.peersData = peersData
|
||||||
self.activationType = tunnelConfiguration?.activationType ?? .activateManually
|
|
||||||
}
|
|
||||||
|
|
||||||
func activateOnDemandOptionText(for activationType: ActivationType) -> String {
|
|
||||||
switch (activationType) {
|
|
||||||
case .activateManually:
|
|
||||||
return ""
|
|
||||||
case .useOnDemandOverWifiAndCellular:
|
|
||||||
return "Over wifi and cellular"
|
|
||||||
case .useOnDemandOverWifiOnly:
|
|
||||||
return "Over wifi only"
|
|
||||||
case .useOnDemandOverCellularOnly:
|
|
||||||
return "Over cellular only"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func appendEmptyPeer() {
|
func appendEmptyPeer() {
|
||||||
|
@ -457,8 +442,29 @@ class TunnelViewModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
let tunnelConfiguration = TunnelConfiguration(interface: interfaceConfiguration, peers: peerConfigurations)
|
let tunnelConfiguration = TunnelConfiguration(interface: interfaceConfiguration, peers: peerConfigurations)
|
||||||
tunnelConfiguration.activationType = self.activationType
|
|
||||||
return .saved(tunnelConfiguration)
|
return .saved(tunnelConfiguration)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: Activate on demand
|
||||||
|
|
||||||
|
extension TunnelViewModel {
|
||||||
|
func activateOnDemandOptionText(for activateOnDemandOption: ActivateOnDemandOption) -> String {
|
||||||
|
switch (activateOnDemandOption) {
|
||||||
|
case .none:
|
||||||
|
return ""
|
||||||
|
case .useOnDemandOverWifiOrCellular:
|
||||||
|
return "Over wifi or cellular"
|
||||||
|
case .useOnDemandOverWifiOnly:
|
||||||
|
return "Over wifi only"
|
||||||
|
case .useOnDemandOverCellularOnly:
|
||||||
|
return "Over cellular only"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func defaultActivateOnDemandOption() -> ActivateOnDemandOption {
|
||||||
|
return .useOnDemandOverWifiOrCellular
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue