summaryrefslogtreecommitdiffhomepage
path: root/talpid-core/src
diff options
context:
space:
mode:
authorJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2018-08-10 15:31:04 -0300
committerJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2018-09-06 08:46:05 -0300
commita49c90dda2c3e5e8bde886b4f1a534223971a4e7 (patch)
treea76f92dda532559f633d329067317bb9ef704b9a /talpid-core/src
parent6312481a9086f84b0e551d802008b173e632769c (diff)
downloadmullvadvpn-a49c90dda2c3e5e8bde886b4f1a534223971a4e7.tar.xz
mullvadvpn-a49c90dda2c3e5e8bde886b4f1a534223971a4e7.zip
Ensure IPv6 can be enabled before starting OpenVPN
Diffstat (limited to 'talpid-core/src')
-rw-r--r--talpid-core/src/tunnel/mod.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/talpid-core/src/tunnel/mod.rs b/talpid-core/src/tunnel/mod.rs
index 9c23bcad59..9ae88a70e9 100644
--- a/talpid-core/src/tunnel/mod.rs
+++ b/talpid-core/src/tunnel/mod.rs
@@ -60,6 +60,10 @@ error_chain!{
CredentialsWriteError {
description("Error while writing credentials to temporary file")
}
+ /// Tunnel can't have IPv6 enabled because the system has disabled IPv6 support.
+ EnableIpv6Error {
+ description("Can't enable IPv6 on tunnel interface because IPv6 is disabled")
+ }
/// Running on an operating system which is not supported yet.
UnsupportedPlatform {
description("Running on an unsupported operating system")
@@ -151,6 +155,7 @@ impl TunnelMonitor {
L: Fn(TunnelEvent) + Send + Sync + 'static,
{
Self::ensure_endpoint_is_openvpn(&tunnel_endpoint)?;
+ Self::ensure_ipv6_can_be_used_if_enabled(tunnel_options)?;
let user_pass_file =
Self::create_user_pass_file(username).chain_err(|| ErrorKind::CredentialsWriteError)?;
@@ -193,6 +198,14 @@ impl TunnelMonitor {
}
}
+ fn ensure_ipv6_can_be_used_if_enabled(tunnel_options: &TunnelOptions) -> Result<()> {
+ if tunnel_options.enable_ipv6 && !is_ipv6_enabled_in_os() {
+ bail!(ErrorKind::EnableIpv6Error);
+ } else {
+ Ok(())
+ }
+ }
+
fn create_openvpn_cmd(
remote: Endpoint,
tunnel_alias: Option<OsString>,
@@ -302,3 +315,7 @@ impl CloseHandle {
self.0.close()
}
}
+
+fn is_ipv6_enabled_in_os() -> bool {
+ true
+}