aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard/WireGuard
diff options
context:
space:
mode:
Diffstat (limited to 'WireGuard/WireGuard')
-rw-r--r--WireGuard/WireGuard/UI/TunnelViewModel.swift9
1 files changed, 7 insertions, 2 deletions
diff --git a/WireGuard/WireGuard/UI/TunnelViewModel.swift b/WireGuard/WireGuard/UI/TunnelViewModel.swift
index 8f95039d..b299bea1 100644
--- a/WireGuard/WireGuard/UI/TunnelViewModel.swift
+++ b/WireGuard/WireGuard/UI/TunnelViewModel.swift
@@ -424,12 +424,17 @@ class TunnelViewModel {
shouldStronglyRecommendDNS = allowedIPStrings.contains(TunnelViewModel.PeerData.ipv4DefaultRouteString) || allowedIPStrings.isSuperset(of: TunnelViewModel.PeerData.ipv4DefaultRouteModRFC1918String)
}
+ static func normalizedIPAddressRangeStrings(_ list: [String]) -> [String] {
+ return list.compactMap { IPAddressRange(from: $0) }.map { $0.stringRepresentation }
+ }
+
static func modifiedAllowedIPs(currentAllowedIPs: [String], excludePrivateIPs: Bool, dnsServers: [String]) -> [String] {
- let ipv6Addresses = currentAllowedIPs.filter { $0.contains(":") }
+ let normalizedDNSServers = normalizedIPAddressRangeStrings(dnsServers)
+ let ipv6Addresses = normalizedIPAddressRangeStrings(currentAllowedIPs.filter { $0.contains(":") })
if excludePrivateIPs {
return ipv6Addresses + TunnelViewModel.PeerData.ipv4DefaultRouteModRFC1918String + dnsServers
} else {
- return ipv6Addresses + [TunnelViewModel.PeerData.ipv4DefaultRouteString]
+ return ipv6Addresses.filter { !normalizedDNSServers.contains($0) } + [TunnelViewModel.PeerData.ipv4DefaultRouteString]
}
}