TunnelViewModel: Remove DNS from AllowedIPs when unchecking 'Exclude private IPs'
This commit is contained in:
parent
226911715c
commit
9cfdbfa1a2
|
@ -424,12 +424,17 @@ class TunnelViewModel {
|
||||||
shouldStronglyRecommendDNS = allowedIPStrings.contains(TunnelViewModel.PeerData.ipv4DefaultRouteString) || allowedIPStrings.isSuperset(of: TunnelViewModel.PeerData.ipv4DefaultRouteModRFC1918String)
|
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] {
|
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 {
|
if excludePrivateIPs {
|
||||||
return ipv6Addresses + TunnelViewModel.PeerData.ipv4DefaultRouteModRFC1918String + dnsServers
|
return ipv6Addresses + TunnelViewModel.PeerData.ipv4DefaultRouteModRFC1918String + dnsServers
|
||||||
} else {
|
} else {
|
||||||
return ipv6Addresses + [TunnelViewModel.PeerData.ipv4DefaultRouteString]
|
return ipv6Addresses.filter { !normalizedDNSServers.contains($0) } + [TunnelViewModel.PeerData.ipv4DefaultRouteString]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue