]> git.ipfire.org Git - thirdparty/wireguard-apple.git/commitdiff
Attempt to strongly recommend things
authorJason A. Donenfeld <Jason@zx2c4.com>
Sat, 22 Dec 2018 00:55:42 +0000 (01:55 +0100)
committerJason A. Donenfeld <Jason@zx2c4.com>
Sat, 22 Dec 2018 00:55:42 +0000 (01:55 +0100)
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
WireGuard/WireGuard/Base.lproj/Localizable.strings
WireGuard/WireGuard/UI/TunnelViewModel.swift
WireGuard/WireGuard/UI/iOS/ViewController/TunnelEditTableViewController.swift

index 58eb9d4884685dd7eee00326a8e562fad15f9f6c..ac4a7300fb3eaa48b95b10c6e8f8af02cef9553a 100644 (file)
@@ -85,6 +85,7 @@
 "tunnelEditPlaceholderTextRequired" = "Required";
 "tunnelEditPlaceholderTextOptional" = "Optional";
 "tunnelEditPlaceholderTextAutomatic" = "Automatic";
+"tunnelEditPlaceholderTextStronglyRecommended" = "Strongly recommended";
 "tunnelEditPlaceholderTextOff" = "Off";
 
 // Error alerts while creating / editing a tunnel configuration
index 0be3cb875ddcba1f20fd7cfec6b18a8a1c6dc8c4..a981ef00d937f4efe81ff1a74fed468c709fc919 100644 (file)
@@ -210,6 +210,7 @@ class TunnelViewModel {
 
         // For exclude private IPs
         private(set) var shouldAllowExcludePrivateIPsControl = false
+        private(set) var shouldStronglyRecommendDNS = false
         private(set) var excludePrivateIPsValue = false
         fileprivate var numberOfPeers = 0
 
@@ -344,15 +345,16 @@ class TunnelViewModel {
         ]
 
         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 {
                 shouldAllowExcludePrivateIPsControl = false
                 excludePrivateIPsValue = false
                 return
             }
-            if scratchpad.isEmpty {
-                populateScratchpad()
-            }
-            let allowedIPStrings = Set<String>(scratchpad[.allowedIPs].splitToArray(trimmingCharacters: .whitespacesAndNewlines))
             if allowedIPStrings.contains(TunnelViewModel.PeerData.ipv4DefaultRouteString) {
                 shouldAllowExcludePrivateIPsControl = true
                 excludePrivateIPsValue = false
index 17e513085ad438f5fbe8d909e3c7f7f8bc75f0ef..db7db6628b38b1224e201e475e81b7ec1a24f644 100644 (file)
@@ -232,8 +232,11 @@ extension TunnelEditTableViewController {
         case .name, .privateKey:
             cell.placeholderText = tr("tunnelEditPlaceholderTextRequired")
             cell.keyboardType = .default
-        case .addresses, .dns:
-            cell.placeholderText = tr("tunnelEditPlaceholderTextOptional")
+        case .addresses:
+            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
         case .listenPort, .mtu:
             cell.placeholderText = tr("tunnelEditPlaceholderTextAutomatic")