diff options
| author | Linus Färnstrand <linus@mullvad.net> | 2017-11-13 13:57:34 +0100 |
|---|---|---|
| committer | Linus Färnstrand <linus@mullvad.net> | 2017-11-13 13:57:34 +0100 |
| commit | 69d942d3841dbf2fa5e75a126855eb424ca89d23 (patch) | |
| tree | 98124ad0a34d8b2fddec6049cf60fdf887a15ed2 /talpid-core | |
| parent | d6b67aca6b07c903e235875f85fbacd3599f40c6 (diff) | |
| parent | ec6084874f19d1451a1a7019ed4d8c1d6b02f780 (diff) | |
| download | mullvadvpn-69d942d3841dbf2fa5e75a126855eb424ca89d23.tar.xz mullvadvpn-69d942d3841dbf2fa5e75a126855eb424ca89d23.zip | |
Merge branch 'introduce-tunnelendpoint'
Diffstat (limited to 'talpid-core')
| -rw-r--r-- | talpid-core/src/tunnel/mod.rs | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/talpid-core/src/tunnel/mod.rs b/talpid-core/src/tunnel/mod.rs index 9b42b64355..af0002c61d 100644 --- a/talpid-core/src/tunnel/mod.rs +++ b/talpid-core/src/tunnel/mod.rs @@ -12,7 +12,7 @@ use std::io::{self, Write}; use std::net::Ipv4Addr; use std::path::{Path, PathBuf}; -use talpid_types::net; +use talpid_types::net::{Endpoint, TunnelEndpoint}; /// A module for all OpenVPN related tunnel management. pub mod openvpn; @@ -38,6 +38,10 @@ mod errors { UnsupportedPlatform { description("Running on an unsupported operating system") } + /// This type of VPN tunnel is not supported. + UnsupportedTunnelTechnology { + description("This tunnel technology is not supported") + } } } } @@ -108,7 +112,7 @@ impl TunnelMonitor { /// Creates a new `TunnelMonitor` that connects to the given remote and notifies `on_event` /// on tunnel state changes. pub fn new<L>( - remote: net::Endpoint, + remote: TunnelEndpoint, account_token: &str, log: Option<&Path>, on_event: L, @@ -116,6 +120,10 @@ impl TunnelMonitor { where L: Fn(TunnelEvent) + Send + Sync + 'static, { + let remote = match remote { + TunnelEndpoint::OpenVpn(endpoint) => endpoint, + _ => bail!(ErrorKind::UnsupportedTunnelTechnology), + }; let user_pass_file = Self::create_user_pass_file(account_token) .chain_err(|| ErrorKind::CredentialsWriteError)?; let cmd = Self::create_openvpn_cmd(remote, user_pass_file.as_ref(), log); @@ -141,7 +149,7 @@ impl TunnelMonitor { } fn create_openvpn_cmd( - remote: net::Endpoint, + remote: Endpoint, user_pass_file: &Path, log: Option<&Path>, ) -> OpenVpnCommand { |
