summaryrefslogtreecommitdiffhomepage
path: root/talpid-core/src
diff options
context:
space:
mode:
authorLinus Färnstrand <linus@mullvad.net>2017-11-10 09:44:00 +0100
committerLinus Färnstrand <linus@mullvad.net>2017-11-13 11:30:46 +0100
commit6279cb71d8f22fc869e7ce0539b7f7c647078f31 (patch)
tree25983378d79e10c845e9bbd64e5f0f0a0318bf6b /talpid-core/src
parentd6b67aca6b07c903e235875f85fbacd3599f40c6 (diff)
downloadmullvadvpn-6279cb71d8f22fc869e7ce0539b7f7c647078f31.tar.xz
mullvadvpn-6279cb71d8f22fc869e7ce0539b7f7c647078f31.zip
Add TunnelEndpoint type
Diffstat (limited to 'talpid-core/src')
-rw-r--r--talpid-core/src/tunnel/mod.rs14
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 {