summaryrefslogtreecommitdiffhomepage
path: root/mullvad-daemon
diff options
context:
space:
mode:
authorDavid Lönnhager <david.l@mullvad.net>2020-10-20 12:35:58 +0200
committerDavid Lönnhager <david.l@mullvad.net>2020-10-26 13:47:00 +0100
commitbd70e62d2ccc8873fefee4e39eae876b03739edd (patch)
tree94e8394baf0c1562d723f14bf628ad23c0fdab31 /mullvad-daemon
parent4331a3fb74d998740d352d78e597ffba6a0c0dd2 (diff)
downloadmullvadvpn-bd70e62d2ccc8873fefee4e39eae876b03739edd.tar.xz
mullvadvpn-bd70e62d2ccc8873fefee4e39eae876b03739edd.zip
Include custom DNS setting on Linux
Diffstat (limited to 'mullvad-daemon')
-rw-r--r--mullvad-daemon/src/lib.rs14
-rw-r--r--mullvad-daemon/src/management_interface.rs10
-rw-r--r--mullvad-daemon/src/settings.rs4
3 files changed, 14 insertions, 14 deletions
diff --git a/mullvad-daemon/src/lib.rs b/mullvad-daemon/src/lib.rs
index 320e839a0a..fa9f679848 100644
--- a/mullvad-daemon/src/lib.rs
+++ b/mullvad-daemon/src/lib.rs
@@ -26,7 +26,7 @@ use futures::{
};
use log::{debug, error, info, warn};
use mullvad_rpc::AccountsProxy;
-#[cfg(windows)]
+#[cfg(any(windows, target_os = "linux"))]
use mullvad_types::settings::DnsOptions;
use mullvad_types::{
account::{AccountData, AccountToken, VoucherSubmission},
@@ -43,7 +43,7 @@ use mullvad_types::{
wireguard::KeygenEvent,
};
use settings::SettingsPersister;
-#[cfg(windows)]
+#[cfg(any(windows, target_os = "linux"))]
use std::net::IpAddr;
#[cfg(not(target_os = "android"))]
use std::path::Path;
@@ -197,7 +197,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)]
+ #[cfg(any(windows, target_os = "linux"))]
SetDnsOptions(oneshot::Sender<()>, DnsOptions),
/// Set MTU for wireguard tunnels
SetWireguardMtu(oneshot::Sender<()>, Option<u16>),
@@ -582,7 +582,7 @@ where
let tunnel_command_tx = tunnel_state_machine::spawn(
settings.allow_lan,
settings.block_when_disconnected,
- #[cfg(windows)]
+ #[cfg(any(windows, target_os = "linux"))]
Self::get_custom_resolvers(&settings.tunnel_options.dns_options),
tunnel_parameters_generator,
log_dir,
@@ -636,7 +636,7 @@ where
Ok(daemon)
}
- #[cfg(windows)]
+ #[cfg(any(windows, target_os = "linux"))]
fn get_custom_resolvers(dns_options: &DnsOptions) -> Option<Vec<IpAddr>> {
if dns_options.custom {
Some(dns_options.addresses.clone())
@@ -1056,7 +1056,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)]
+ #[cfg(any(windows, target_os = "linux"))]
SetDnsOptions(tx, dns_servers) => self.on_set_dns_options(tx, dns_servers),
SetWireguardMtu(tx, mtu) => self.on_set_wireguard_mtu(tx, mtu),
SetWireguardRotationInterval(tx, interval) => {
@@ -1696,7 +1696,7 @@ where
}
}
- #[cfg(windows)]
+ #[cfg(any(windows, target_os = "linux"))]
fn on_set_dns_options(&mut self, tx: oneshot::Sender<()>, dns_options: DnsOptions) {
let save_result = self.settings.set_dns_options(dns_options.clone());
match save_result {
diff --git a/mullvad-daemon/src/management_interface.rs b/mullvad-daemon/src/management_interface.rs
index ca324308cb..d248a10dc5 100644
--- a/mullvad-daemon/src/management_interface.rs
+++ b/mullvad-daemon/src/management_interface.rs
@@ -6,7 +6,7 @@ use mullvad_management_interface::{
};
use mullvad_paths;
use mullvad_rpc::{rest::Error as RestError, StatusCode};
-#[cfg(windows)]
+#[cfg(any(windows, target_os = "linux"))]
use mullvad_types::settings::DnsOptions;
use mullvad_types::{
account::AccountToken,
@@ -410,7 +410,7 @@ impl ManagementService for ManagementServiceImpl {
.map_err(|_| Status::internal("internal error"))
}
- #[cfg(windows)]
+ #[cfg(any(windows, target_os = "linux"))]
async fn set_dns_options(&self, request: Request<types::DnsOptions>) -> ServiceResult<()> {
let options = request.into_inner();
log::debug!(
@@ -441,7 +441,7 @@ impl ManagementService for ManagementServiceImpl {
.map(Response::new)
.map_err(|_| Status::internal("internal error"))
}
- #[cfg(not(windows))]
+ #[cfg(not(any(windows, target_os = "linux")))]
async fn set_dns_options(&self, _: Request<types::DnsOptions>) -> ServiceResult<()> {
Ok(Response::new(()))
}
@@ -1179,7 +1179,7 @@ fn convert_tunnel_options(options: &TunnelOptions) -> types::TunnelOptions {
generic: Some(types::tunnel_options::GenericOptions {
enable_ipv6: options.generic.enable_ipv6,
}),
- #[cfg(windows)]
+ #[cfg(any(windows, target_os = "linux"))]
dns_options: Some(types::DnsOptions {
custom: options.dns_options.custom,
addresses: options
@@ -1189,7 +1189,7 @@ fn convert_tunnel_options(options: &TunnelOptions) -> types::TunnelOptions {
.map(|addr| addr.to_string())
.collect(),
}),
- #[cfg(not(windows))]
+ #[cfg(not(any(windows, target_os = "linux")))]
dns_options: None,
}
}
diff --git a/mullvad-daemon/src/settings.rs b/mullvad-daemon/src/settings.rs
index bcc07f84ae..f9986c49a5 100644
--- a/mullvad-daemon/src/settings.rs
+++ b/mullvad-daemon/src/settings.rs
@@ -1,5 +1,5 @@
use log::{debug, error, info};
-#[cfg(windows)]
+#[cfg(any(windows, target_os = "linux"))]
use mullvad_types::settings::DnsOptions;
use mullvad_types::{
relay_constraints::{BridgeSettings, BridgeState, RelaySettingsUpdate},
@@ -212,7 +212,7 @@ impl SettingsPersister {
self.update(should_save)
}
- #[cfg(windows)]
+ #[cfg(any(windows, target_os = "linux"))]
pub fn set_dns_options(&mut self, options: DnsOptions) -> Result<bool, Error> {
let should_save =
Self::update_field(&mut self.settings.tunnel_options.dns_options, options);