diff options
| author | David Lönnhager <david.l@mullvad.net> | 2024-09-24 18:29:50 +0200 |
|---|---|---|
| committer | David Lönnhager <david.l@mullvad.net> | 2024-09-25 10:41:55 +0200 |
| commit | b668c86084af4086218d661b2f62145e9764335f (patch) | |
| tree | 53d3a2c632fc50deac30ed18c30f0d222f9198a3 | |
| parent | 7b54ec3f5b824438cf10c47d101fdd85d60c2b40 (diff) | |
| download | mullvadvpn-b668c86084af4086218d661b2f62145e9764335f.tar.xz mullvadvpn-b668c86084af4086218d661b2f62145e9764335f.zip | |
Do not touch DNS config if localhost is used
Co-authored-by: Markus Pettersson <markus.pettersson@mullvad.net>
| -rw-r--r-- | talpid-core/src/dns/macos.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/talpid-core/src/dns/macos.rs b/talpid-core/src/dns/macos.rs index 78f4550688..dbfd056d01 100644 --- a/talpid-core/src/dns/macos.rs +++ b/talpid-core/src/dns/macos.rs @@ -173,6 +173,10 @@ impl State { match settings { // Do nothing if the state is already what we want Some(settings) if settings.address_set() == desired_set => (), + // Ignore loopback addresses + Some(settings) if settings.ips().any(|ip| ip.is_loopback()) => { + log::trace!("Not updating DNS config: localhost is used"); + } // Apply desired state to service _ => { let path_cf = CFString::new(path); @@ -280,6 +284,12 @@ impl DnsSettings { BTreeSet::from_iter(self.server_addresses()) } + pub fn ips(&self) -> impl Iterator<Item = IpAddr> { + self.server_addresses() + .into_iter() + .filter_map(|addr| addr.parse::<IpAddr>().ok()) + } + /// Parses a CFArray into a Rust vector of Rust strings, if the array contains CFString /// instances only, otherwise `None` is returned. fn parse_cf_array_to_strings(array: CFArray) -> Option<Vec<String>> { |
