Attempt to strongly recommend things
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
parent
aede9f6e45
commit
41a4c6362a
|
@ -85,6 +85,7 @@
|
||||||
"tunnelEditPlaceholderTextRequired" = "Required";
|
"tunnelEditPlaceholderTextRequired" = "Required";
|
||||||
"tunnelEditPlaceholderTextOptional" = "Optional";
|
"tunnelEditPlaceholderTextOptional" = "Optional";
|
||||||
"tunnelEditPlaceholderTextAutomatic" = "Automatic";
|
"tunnelEditPlaceholderTextAutomatic" = "Automatic";
|
||||||
|
"tunnelEditPlaceholderTextStronglyRecommended" = "Strongly recommended";
|
||||||
"tunnelEditPlaceholderTextOff" = "Off";
|
"tunnelEditPlaceholderTextOff" = "Off";
|
||||||
|
|
||||||
// Error alerts while creating / editing a tunnel configuration
|
// Error alerts while creating / editing a tunnel configuration
|
||||||
|
|
|
@ -210,6 +210,7 @@ class TunnelViewModel {
|
||||||
|
|
||||||
// For exclude private IPs
|
// For exclude private IPs
|
||||||
private(set) var shouldAllowExcludePrivateIPsControl = false
|
private(set) var shouldAllowExcludePrivateIPsControl = false
|
||||||
|
private(set) var shouldStronglyRecommendDNS = false
|
||||||
private(set) var excludePrivateIPsValue = false
|
private(set) var excludePrivateIPsValue = false
|
||||||
fileprivate var numberOfPeers = 0
|
fileprivate var numberOfPeers = 0
|
||||||
|
|
||||||
|
@ -344,15 +345,16 @@ class TunnelViewModel {
|
||||||
]
|
]
|
||||||
|
|
||||||
func updateExcludePrivateIPsFieldState() {
|
func updateExcludePrivateIPsFieldState() {
|
||||||
|
if scratchpad.isEmpty {
|
||||||
|
populateScratchpad()
|
||||||
|
}
|
||||||
|
let allowedIPStrings = Set<String>(scratchpad[.allowedIPs].splitToArray(trimmingCharacters: .whitespacesAndNewlines))
|
||||||
|
shouldStronglyRecommendDNS = allowedIPStrings.contains(TunnelViewModel.PeerData.ipv4DefaultRouteString) || allowedIPStrings.isSuperset(of: TunnelViewModel.PeerData.ipv4DefaultRouteModRFC1918String)
|
||||||
guard numberOfPeers == 1 else {
|
guard numberOfPeers == 1 else {
|
||||||
shouldAllowExcludePrivateIPsControl = false
|
shouldAllowExcludePrivateIPsControl = false
|
||||||
excludePrivateIPsValue = false
|
excludePrivateIPsValue = false
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if scratchpad.isEmpty {
|
|
||||||
populateScratchpad()
|
|
||||||
}
|
|
||||||
let allowedIPStrings = Set<String>(scratchpad[.allowedIPs].splitToArray(trimmingCharacters: .whitespacesAndNewlines))
|
|
||||||
if allowedIPStrings.contains(TunnelViewModel.PeerData.ipv4DefaultRouteString) {
|
if allowedIPStrings.contains(TunnelViewModel.PeerData.ipv4DefaultRouteString) {
|
||||||
shouldAllowExcludePrivateIPsControl = true
|
shouldAllowExcludePrivateIPsControl = true
|
||||||
excludePrivateIPsValue = false
|
excludePrivateIPsValue = false
|
||||||
|
|
|
@ -232,8 +232,11 @@ extension TunnelEditTableViewController {
|
||||||
case .name, .privateKey:
|
case .name, .privateKey:
|
||||||
cell.placeholderText = tr("tunnelEditPlaceholderTextRequired")
|
cell.placeholderText = tr("tunnelEditPlaceholderTextRequired")
|
||||||
cell.keyboardType = .default
|
cell.keyboardType = .default
|
||||||
case .addresses, .dns:
|
case .addresses:
|
||||||
cell.placeholderText = tr("tunnelEditPlaceholderTextOptional")
|
cell.placeholderText = tr("tunnelEditPlaceholderTextStronglyRecommended")
|
||||||
|
cell.keyboardType = .numbersAndPunctuation
|
||||||
|
case .dns:
|
||||||
|
cell.placeholderText = tunnelViewModel.peersData.contains(where: { return $0.shouldStronglyRecommendDNS }) ? tr("tunnelEditPlaceholderTextStronglyRecommended") : tr("tunnelEditPlaceholderTextOptional")
|
||||||
cell.keyboardType = .numbersAndPunctuation
|
cell.keyboardType = .numbersAndPunctuation
|
||||||
case .listenPort, .mtu:
|
case .listenPort, .mtu:
|
||||||
cell.placeholderText = tr("tunnelEditPlaceholderTextAutomatic")
|
cell.placeholderText = tr("tunnelEditPlaceholderTextAutomatic")
|
||||||
|
|
Loading…
Reference in New Issue