diff options
| author | David Lönnhager <david.l@mullvad.net> | 2020-10-19 12:12:40 +0200 |
|---|---|---|
| committer | David Lönnhager <david.l@mullvad.net> | 2020-10-22 09:33:59 +0200 |
| commit | 83290680cc26ced9963f1798cd2290f309b01132 (patch) | |
| tree | 5b819799d1713b433b2b5369d0b7d49b965783df /mullvad-daemon/src | |
| parent | a4125e81f559bebf24e94934676537270e2dc917 (diff) | |
| download | mullvadvpn-83290680cc26ced9963f1798cd2290f309b01132.tar.xz mullvadvpn-83290680cc26ced9963f1798cd2290f309b01132.zip | |
Use custom DNS setting on Windows only
Diffstat (limited to 'mullvad-daemon/src')
| -rw-r--r-- | mullvad-daemon/src/lib.rs | 8 | ||||
| -rw-r--r-- | mullvad-daemon/src/management_interface.rs | 8 | ||||
| -rw-r--r-- | mullvad-daemon/src/settings.rs | 4 |
3 files changed, 17 insertions, 3 deletions
diff --git a/mullvad-daemon/src/lib.rs b/mullvad-daemon/src/lib.rs index 3acf4eb11d..7f5b85f7e0 100644 --- a/mullvad-daemon/src/lib.rs +++ b/mullvad-daemon/src/lib.rs @@ -41,6 +41,8 @@ use mullvad_types::{ wireguard::KeygenEvent, }; use settings::SettingsPersister; +#[cfg(windows)] +use std::net::IpAddr; #[cfg(not(target_os = "android"))] use std::path::Path; use std::{ @@ -48,7 +50,6 @@ use std::{ io, marker::PhantomData, mem, - net::IpAddr, path::PathBuf, sync::{mpsc as sync_mpsc, Arc, Weak}, time::Duration, @@ -194,6 +195,7 @@ pub enum DaemonCommand { /// Set if IPv6 should be enabled in the tunnel SetEnableIpv6(oneshot::Sender<()>, bool), /// Set custom DNS servers to use instead of passing requests to the gateway + #[cfg(windows)] SetCustomDns(oneshot::Sender<()>, Option<Vec<IpAddr>>), /// Set MTU for wireguard tunnels SetWireguardMtu(oneshot::Sender<()>, Option<u16>), @@ -575,10 +577,10 @@ where TargetState::Unsecured }; - let tunnel_command_tx = tunnel_state_machine::spawn( settings.allow_lan, settings.block_when_disconnected, + #[cfg(windows)] settings.tunnel_options.generic.custom_dns.clone(), tunnel_parameters_generator, log_dir, @@ -1043,6 +1045,7 @@ where } SetBridgeState(tx, bridge_state) => self.on_set_bridge_state(tx, bridge_state), SetEnableIpv6(tx, enable_ipv6) => self.on_set_enable_ipv6(tx, enable_ipv6), + #[cfg(windows)] SetCustomDns(tx, dns_servers) => self.on_set_custom_dns(tx, dns_servers), SetWireguardMtu(tx, mtu) => self.on_set_wireguard_mtu(tx, mtu), SetWireguardRotationInterval(tx, interval) => { @@ -1682,6 +1685,7 @@ where } } + #[cfg(windows)] fn on_set_custom_dns(&mut self, tx: oneshot::Sender<()>, servers: Option<Vec<IpAddr>>) { let save_result = self.settings.set_custom_dns(servers.clone()); match save_result { diff --git a/mullvad-daemon/src/management_interface.rs b/mullvad-daemon/src/management_interface.rs index 50caacc005..a5cfebedc3 100644 --- a/mullvad-daemon/src/management_interface.rs +++ b/mullvad-daemon/src/management_interface.rs @@ -408,6 +408,7 @@ impl ManagementService for ManagementServiceImpl { .map_err(|_| Status::internal("internal error")) } + #[cfg(windows)] async fn set_custom_dns(&self, request: Request<types::CustomDns>) -> ServiceResult<()> { let servers = request.into_inner(); log::debug!("set_custom_dns({:?})", servers.addresses); @@ -434,6 +435,10 @@ impl ManagementService for ManagementServiceImpl { .map(Response::new) .map_err(|_| Status::internal("internal error")) } + #[cfg(not(windows))] + async fn set_custom_dns(&self, _: Request<types::CustomDns>) -> ServiceResult<()> { + Ok(Response::new(())) + } // Account management // @@ -1167,6 +1172,7 @@ fn convert_tunnel_options(options: &TunnelOptions) -> types::TunnelOptions { }), generic: Some(types::tunnel_options::GenericOptions { enable_ipv6: options.generic.enable_ipv6, + #[cfg(windows)] custom_dns: options .generic .custom_dns @@ -1174,6 +1180,8 @@ fn convert_tunnel_options(options: &TunnelOptions) -> types::TunnelOptions { .map(|addresses| types::CustomDns { addresses: addresses.iter().map(|addr| addr.to_string()).collect(), }), + #[cfg(not(windows))] + custom_dns: None, }), } } diff --git a/mullvad-daemon/src/settings.rs b/mullvad-daemon/src/settings.rs index c0a983fe51..1f6f6a447c 100644 --- a/mullvad-daemon/src/settings.rs +++ b/mullvad-daemon/src/settings.rs @@ -3,10 +3,11 @@ use mullvad_types::{ relay_constraints::{BridgeSettings, BridgeState, RelaySettingsUpdate}, settings::Settings, }; +#[cfg(windows)] +use std::net::IpAddr; use std::{ fs::{self, File}, io, - net::IpAddr, ops::Deref, path::{Path, PathBuf}, }; @@ -211,6 +212,7 @@ impl SettingsPersister { self.update(should_save) } + #[cfg(windows)] pub fn set_custom_dns(&mut self, servers: Option<Vec<IpAddr>>) -> Result<bool, Error> { let should_save = Self::update_field( &mut self.settings.tunnel_options.generic.custom_dns, |
