summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--mullvad-daemon/src/main.rs16
-rw-r--r--mullvad-daemon/src/management_interface.rs23
-rw-r--r--mullvad-daemon/src/settings.rs9
3 files changed, 47 insertions, 1 deletions
diff --git a/mullvad-daemon/src/main.rs b/mullvad-daemon/src/main.rs
index db322d8155..e9a02a77f3 100644
--- a/mullvad-daemon/src/main.rs
+++ b/mullvad-daemon/src/main.rs
@@ -389,6 +389,9 @@ impl Daemon {
SetAutoConnect(tx, auto_connect) => self.on_set_auto_connect(tx, auto_connect),
GetAutoConnect(tx) => Ok(self.on_get_auto_connect(tx)),
SetOpenVpnMssfix(tx, mssfix_arg) => self.on_set_openvpn_mssfix(tx, mssfix_arg),
+ SetOpenVpnEnableIpv6(tx, enable_ipv6) => {
+ self.on_set_openvpn_enable_ipv6(tx, enable_ipv6)
+ }
GetTunnelOptions(tx) => self.on_get_tunnel_options(tx),
GetRelaySettings(tx) => Ok(self.on_get_relay_settings(tx)),
GetVersionInfo(tx) => Ok(self.on_get_version_info(tx)),
@@ -577,6 +580,19 @@ impl Daemon {
Ok(())
}
+ fn on_set_openvpn_enable_ipv6(
+ &mut self,
+ tx: OneshotSender<()>,
+ enable_ipv6: bool,
+ ) -> Result<()> {
+ let save_result = self.settings.set_openvpn_enable_ipv6(enable_ipv6);
+ match save_result.chain_err(|| "Unable to save settings") {
+ Ok(_) => Self::oneshot_send(tx, (), "set_openvpn_enable_ipv6 response"),
+ Err(e) => error!("{}", e.display_chain()),
+ };
+ Ok(())
+ }
+
fn on_get_tunnel_options(&self, tx: OneshotSender<TunnelOptions>) -> Result<()> {
let tunnel_options = self.settings.get_tunnel_options().clone();
Self::oneshot_send(tx, tunnel_options, "get_tunnel_options response");
diff --git a/mullvad-daemon/src/management_interface.rs b/mullvad-daemon/src/management_interface.rs
index 230e478afb..2a77650a52 100644
--- a/mullvad-daemon/src/management_interface.rs
+++ b/mullvad-daemon/src/management_interface.rs
@@ -127,6 +127,10 @@ build_rpc_trait! {
#[rpc(meta, name = "set_openvpn_mssfix")]
fn set_openvpn_mssfix(&self, Self::Metadata, Option<u16>) -> BoxFuture<(), Error>;
+ /// Set if IPv6 is enabled in the tunnel
+ #[rpc(meta, name = "set_openvpn_enable_ipv6")]
+ fn set_openvpn_enable_ipv6(&self, Self::Metadata, bool) -> BoxFuture<(), Error>;
+
/// Gets tunnel specific options
#[rpc(meta, name = "get_tunnel_options")]
fn get_tunnel_options(&self, Self::Metadata) -> BoxFuture<TunnelOptions, Error>;
@@ -195,7 +199,9 @@ pub enum TunnelCommand {
GetAutoConnect(OneshotSender<bool>),
/// Set the mssfix argument for OpenVPN
SetOpenVpnMssfix(OneshotSender<()>, Option<u16>),
- /// Get the mssfix argument for OpenVPN
+ /// Set if IPv6 should be enabled in the tunnel
+ SetOpenVpnEnableIpv6(OneshotSender<()>, bool),
+ /// Get the tunnel options
GetTunnelOptions(OneshotSender<TunnelOptions>),
/// Get information about the currently running and latest app versions
GetVersionInfo(OneshotSender<BoxFuture<version::AppVersionInfo, mullvad_rpc::Error>>),
@@ -637,6 +643,21 @@ impl<T: From<TunnelCommand> + 'static + Send> ManagementInterfaceApi for Managem
Box::new(future)
}
+ fn set_openvpn_enable_ipv6(
+ &self,
+ meta: Self::Metadata,
+ enable_ipv6: bool,
+ ) -> BoxFuture<(), Error> {
+ trace!("set_openvpn_enable_ipv6");
+ try_future!(self.check_auth(&meta));
+ let (tx, rx) = sync::oneshot::channel();
+ let future = self
+ .send_command_to_daemon(TunnelCommand::SetOpenVpnEnableIpv6(tx, enable_ipv6))
+ .and_then(|_| rx.map_err(|_| Error::internal_error()));
+
+ Box::new(future)
+ }
+
fn get_tunnel_options(&self, meta: Self::Metadata) -> BoxFuture<TunnelOptions, Error> {
trace!("get_tunnel_options");
try_future!(self.check_auth(&meta));
diff --git a/mullvad-daemon/src/settings.rs b/mullvad-daemon/src/settings.rs
index b11b80017a..4256735cdf 100644
--- a/mullvad-daemon/src/settings.rs
+++ b/mullvad-daemon/src/settings.rs
@@ -180,6 +180,15 @@ impl Settings {
}
}
+ pub fn set_openvpn_enable_ipv6(&mut self, enable_ipv6: bool) -> Result<bool> {
+ if self.tunnel_options.openvpn.enable_ipv6 != enable_ipv6 {
+ self.tunnel_options.openvpn.enable_ipv6 = enable_ipv6;
+ self.save().map(|_| true)
+ } else {
+ Ok(false)
+ }
+ }
+
pub fn get_tunnel_options(&self) -> &TunnelOptions {
&self.tunnel_options
}