diff options
| author | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2019-05-15 10:42:40 +0000 |
|---|---|---|
| committer | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2019-05-16 13:56:03 +0000 |
| commit | fa1093edde04eadb1cf39dfa34ccf35e8988d511 (patch) | |
| tree | 24b10466d768784645c9b580e4bea4c278704506 | |
| parent | 858b44484c9cc12c364191fb89d4ec6146c8d720 (diff) | |
| download | mullvadvpn-fa1093edde04eadb1cf39dfa34ccf35e8988d511.tar.xz mullvadvpn-fa1093edde04eadb1cf39dfa34ccf35e8988d511.zip | |
Don't include OpenVPN on Android
| -rw-r--r-- | talpid-core/src/tunnel/mod.rs | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/talpid-core/src/tunnel/mod.rs b/talpid-core/src/tunnel/mod.rs index baa5a906ba..17b23b9e12 100644 --- a/talpid-core/src/tunnel/mod.rs +++ b/talpid-core/src/tunnel/mod.rs @@ -1,15 +1,19 @@ use crate::logging; +#[cfg(not(target_os = "android"))] +use std::collections::HashMap; use std::{ - collections::HashMap, io, net::{IpAddr, Ipv4Addr, Ipv6Addr}, path::{Path, PathBuf}, }; +#[cfg(not(target_os = "android"))] +use talpid_types::net::openvpn as openvpn_types; #[cfg(any(target_os = "linux", target_os = "macos"))] use talpid_types::net::wireguard as wireguard_types; -use talpid_types::net::{openvpn as openvpn_types, GenericTunnelOptions, TunnelParameters}; +use talpid_types::net::{GenericTunnelOptions, TunnelParameters}; /// A module for all OpenVPN related tunnel management. +#[cfg(not(target_os = "android"))] pub mod openvpn; #[cfg(any(target_os = "linux", target_os = "macos"))] @@ -42,6 +46,7 @@ pub enum Error { WireguardConfigError(#[error(cause)] self::wireguard::config::Error), /// There was an error listening for events from the OpenVPN tunnel + #[cfg(not(target_os = "android"))] #[error(display = "Failed while listening for events from the OpenVPN tunnel")] OpenVpnTunnelMonitoringError(#[error(cause)] openvpn::Error), @@ -76,6 +81,7 @@ pub struct TunnelMetadata { pub ipv6_gateway: Option<Ipv6Addr>, } +#[cfg(not(target_os = "android"))] impl TunnelEvent { /// Converts an `openvpn_plugin::EventType` to a `TunnelEvent`. /// Returns `None` if there is no corresponding `TunnelEvent`. @@ -142,6 +148,7 @@ impl TunnelMonitor { let log_file = Self::prepare_tunnel_log_file(&tunnel_parameters, log_dir)?; match tunnel_parameters { + #[cfg(not(target_os = "android"))] TunnelParameters::OpenVpn(config) => { Self::start_openvpn_tunnel(&config, log_file, resource_dir, on_event) } @@ -149,6 +156,8 @@ impl TunnelMonitor { TunnelParameters::Wireguard(config) => { Self::start_wireguard_tunnel(&config, log_file, on_event) } + #[cfg(target_os = "android")] + TunnelParameters::OpenVpn(_) => Err(Error::UnsupportedPlatform), #[cfg(any(windows, target_os = "android"))] TunnelParameters::Wireguard(_) => Err(Error::UnsupportedPlatform), } @@ -174,6 +183,7 @@ impl TunnelMonitor { }) } + #[cfg(not(target_os = "android"))] fn start_openvpn_tunnel<L>( config: &openvpn_types::TunnelParameters, log: Option<PathBuf>, @@ -231,6 +241,7 @@ impl TunnelMonitor { /// A handle to a `TunnelMonitor` pub enum CloseHandle { + #[cfg(not(target_os = "android"))] /// OpenVpn close handle OpenVpn(openvpn::OpenVpnCloseHandle), #[cfg(any(target_os = "linux", target_os = "macos"))] @@ -241,6 +252,10 @@ pub enum CloseHandle { impl CloseHandle { /// Closes the underlying tunnel, making the `TunnelMonitor::wait` method return. pub fn close(self) -> io::Result<()> { + #[cfg(target_os = "android")] + unimplemented!(); + + #[cfg(not(target_os = "android"))] match self { CloseHandle::OpenVpn(handle) => handle.close(), #[cfg(any(target_os = "linux", target_os = "macos"))] @@ -253,6 +268,7 @@ impl CloseHandle { } enum InternalTunnelMonitor { + #[cfg(not(target_os = "android"))] OpenVpn(openvpn::OpenVpnMonitor), #[cfg(any(target_os = "linux", target_os = "macos"))] Wireguard(wireguard::WireguardMonitor), @@ -260,14 +276,19 @@ enum InternalTunnelMonitor { impl InternalTunnelMonitor { fn close_handle(&self) -> CloseHandle { + #[cfg(not(target_os = "android"))] match self { InternalTunnelMonitor::OpenVpn(tun) => CloseHandle::OpenVpn(tun.close_handle()), #[cfg(any(target_os = "linux", target_os = "macos"))] InternalTunnelMonitor::Wireguard(tun) => CloseHandle::Wireguard(tun.close_handle()), } + + #[cfg(target_os = "android")] + unimplemented!(); } fn wait(self) -> Result<()> { + #[cfg(not(target_os = "android"))] match self { InternalTunnelMonitor::OpenVpn(tun) => tun.wait()?, #[cfg(any(target_os = "linux", target_os = "macos"))] |
