Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't hijack DNS config when localhost is used #6861

Merged
merged 2 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ Line wrap the file at 100 chars. Th
#### macOS
- Disable split tunnel interface when disconnected. This prevents traffic from being sent through
the daemon when the VPN is disconnected.
- Don't hijack DNS when localhost is configured. This is more in line with other platforms.
Unexpected DNS traffic is still blocked when leaving the host.

### Fixed
#### Linux
Expand Down
10 changes: 10 additions & 0 deletions talpid-core/src/dns/macos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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>> {
Expand Down
Loading