diff options
| -rw-r--r-- | talpid-core/src/tunnel/mod.rs | 17 |
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 +} |
