summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2018-07-18 09:34:34 -0300
committerJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2018-07-18 09:34:34 -0300
commit9f0ed3cc4878edac9aa8ae67fae366cb1d0bf588 (patch)
tree6730a26271c91d0e4cbb939adf27c14a645e2d17
parent8e3708da9a4f87d779e8a0ef5c04f1668f301ad3 (diff)
parenta31b9ff86be652a11ef69ae88699d78e9a9c9c8a (diff)
downloadmullvadvpn-9f0ed3cc4878edac9aa8ae67fae366cb1d0bf588.tar.xz
mullvadvpn-9f0ed3cc4878edac9aa8ae67fae366cb1d0bf588.zip
Merge branch 'set-openvpn-iproute-command'
-rw-r--r--Cargo.lock43
-rw-r--r--talpid-core/Cargo.toml2
-rw-r--r--talpid-core/src/lib.rs4
-rw-r--r--talpid-core/src/process/openvpn.rs13
-rw-r--r--talpid-core/src/tunnel/mod.rs16
5 files changed, 78 insertions, 0 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 008ddd3d9b..d3586e4253 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -318,6 +318,25 @@ dependencies = [
]
[[package]]
+name = "failure"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "backtrace 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
+ "failure_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "failure_derive"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
+ "syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)",
+ "synstructure 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
name = "fern"
version = "0.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1409,6 +1428,15 @@ dependencies = [
]
[[package]]
+name = "synstructure"
+version = "0.6.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
+ "syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
name = "system-configuration"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1438,6 +1466,7 @@ dependencies = [
"core-foundation 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"duct 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"ipnetwork 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)",
"jsonrpc-core 8.0.1 (git+https://github.com/paritytech/jsonrpc?tag=v8.0.1)",
"jsonrpc-macros 8.0.0 (git+https://github.com/paritytech/jsonrpc?tag=v8.0.1)",
@@ -1458,6 +1487,7 @@ dependencies = [
"tempfile 3.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-core 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)",
"uuid 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "which 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"widestring 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -1827,6 +1857,15 @@ dependencies = [
]
[[package]]
+name = "which"
+version = "2.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
name = "widestring"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1957,6 +1996,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum errno 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b2c858c42ac0b88532f48fca88b0ed947cad4f1f64d904bcd6c9f138f7b95d70"
"checksum error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ff511d5dc435d703f4971bc399647c9bc38e20cb41452e3b9feb4765419ed3f3"
"checksum error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "07e791d3be96241c77c43846b665ef1384606da2cd2a48730abe606a12906e02"
+"checksum failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "934799b6c1de475a012a02dab0ace1ace43789ee4b99bcfbf1a2e3e8ced5de82"
+"checksum failure_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c7cdda555bb90c9bb67a3b670a0f42de8e73f5981524123ad8578aafec8ddb8b"
"checksum fern 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "de237898aa785d93b869e965132f62a525b90cce5c0bf2a395f03e62e085bc5c"
"checksum filetime 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "714653f3e34871534de23771ac7b26e999651a0a228f47beb324dfdf1dd4b10f"
"checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3"
@@ -2068,6 +2109,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad"
"checksum syn 0.13.4 (registry+https://github.com/rust-lang/crates.io-index)" = "90d5efaad92a0f96c629ae16302cc9591915930fd49ff0dcc6b4cde146782397"
"checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6"
+"checksum synstructure 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3a761d12e6d8dcb4dcf952a7a89b475e3a9d69e4a69307e01a470977642914bd"
"checksum system-configuration 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2646789845add5fa0adcbe7684cb89509ae98c404284471bf4f9faf995d88a58"
"checksum system-configuration-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7d8b463ff8bb4585b46e3e23f44dd41b3f52d0ad09b6b9cf03aae55c74d74cff"
"checksum take 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b157868d8ac1f56b64604539990685fa7611d8fa9e5476cf0c02cf34d32917c5"
@@ -2107,6 +2149,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum version_check 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6b772017e347561807c1aa192438c5fd74242a670a6cffacc40f2defd1dc069d"
"checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
"checksum walkdir 2.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "63636bd0eb3d00ccb8b9036381b526efac53caf112b7783b730ab3f8e44da369"
+"checksum which 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "49c4f580e93079b70ac522e7bdebbe1568c8afa7d8d05ee534ee737ca37d2f51"
"checksum widestring 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a212922ea58fbf5044f83663aa4fc6281ff890f1fd7546c0c3f52f5290831781"
"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
"checksum winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "773ef9dcc5f24b7d850d0ff101e542ff24c3b090a9768e03ff889fdef41f00fd"
diff --git a/talpid-core/Cargo.toml b/talpid-core/Cargo.toml
index 1040ebb007..a3601c79ec 100644
--- a/talpid-core/Cargo.toml
+++ b/talpid-core/Cargo.toml
@@ -26,10 +26,12 @@ ipnetwork = "0.13"
lazy_static = "1.0"
[target.'cfg(target_os = "linux")'.dependencies]
+failure = "0.1"
notify = "4.0"
resolv-conf = "0.6.1"
nftnl = { git = "https://github.com/mullvad/nftnl-rs", features = ["nftnl-1-1-0"] }
mnl = { git = "https://github.com/mullvad/mnl-rs", features = ["mnl-1-0-4"] }
+which = "2.0"
[target.'cfg(target_os = "macos")'.dependencies]
pfctl = "0.2"
diff --git a/talpid-core/src/lib.rs b/talpid-core/src/lib.rs
index fd26752fac..de3bd84ea6 100644
--- a/talpid-core/src/lib.rs
+++ b/talpid-core/src/lib.rs
@@ -17,6 +17,8 @@ extern crate log;
#[macro_use]
extern crate error_chain;
+#[cfg(target_os = "linux")]
+extern crate failure;
#[cfg(unix)]
extern crate ipnetwork;
extern crate jsonrpc_core;
@@ -28,6 +30,8 @@ extern crate lazy_static;
extern crate libc;
extern crate shell_escape;
extern crate uuid;
+#[cfg(target_os = "linux")]
+extern crate which;
extern crate openvpn_plugin;
extern crate talpid_ipc;
diff --git a/talpid-core/src/process/openvpn.rs b/talpid-core/src/process/openvpn.rs
index 0a5e93a084..409cc605a7 100644
--- a/talpid-core/src/process/openvpn.rs
+++ b/talpid-core/src/process/openvpn.rs
@@ -48,6 +48,7 @@ pub struct OpenVpnCommand {
user_pass_path: Option<PathBuf>,
ca: Option<PathBuf>,
crl: Option<PathBuf>,
+ iproute_bin: Option<OsString>,
plugin: Option<(PathBuf, Vec<String>)>,
log: Option<PathBuf>,
tunnel_options: net::OpenVpnTunnelOptions,
@@ -65,6 +66,7 @@ impl OpenVpnCommand {
user_pass_path: None,
ca: None,
crl: None,
+ iproute_bin: None,
plugin: None,
log: None,
tunnel_options: net::OpenVpnTunnelOptions::default(),
@@ -103,6 +105,12 @@ impl OpenVpnCommand {
self
}
+ /// Sets the path to the ip route command.
+ pub fn iproute_bin<S: Into<OsString>>(&mut self, iproute_bin: S) -> &mut Self {
+ self.iproute_bin = Some(iproute_bin.into());
+ self
+ }
+
/// Sets a plugin and its arguments that OpenVPN will be started with.
pub fn plugin<P: AsRef<Path>>(&mut self, path: P, args: Vec<String>) -> &mut Self {
self.plugin = Some((path.as_ref().to_path_buf(), args));
@@ -146,6 +154,11 @@ impl OpenVpnCommand {
args.extend(self.remote_arguments().iter().map(OsString::from));
args.extend(self.authentication_arguments());
+ if let Some(ref iproute_bin) = self.iproute_bin {
+ args.push(OsString::from("--iproute"));
+ args.push(iproute_bin.clone());
+ }
+
if let Some(ref ca) = self.ca {
args.push(OsString::from("--ca"));
args.push(OsString::from(ca.as_os_str()));
diff --git a/talpid-core/src/tunnel/mod.rs b/talpid-core/src/tunnel/mod.rs
index cd90924ac1..932279c0a0 100644
--- a/talpid-core/src/tunnel/mod.rs
+++ b/talpid-core/src/tunnel/mod.rs
@@ -11,6 +11,11 @@ use std::io::{self, Write};
use std::net::Ipv4Addr;
use std::path::{Path, PathBuf};
+#[cfg(target_os = "linux")]
+use failure::ResultExt as FailureResultExt;
+#[cfg(target_os = "linux")]
+use which;
+
use talpid_types::net::{
Endpoint, OpenVpnTunnelOptions, TunnelEndpoint, TunnelEndpointData, TunnelOptions,
};
@@ -43,6 +48,11 @@ error_chain!{
description("No OpenVPN binary found")
display("No OpenVPN binary found at {}", path.display())
}
+ /// The IP routing program was not found.
+ #[cfg(target_os = "linux")]
+ IpRouteNotFound {
+ description("The IP routing program `ip` was not found.")
+ }
/// The OpenVPN plugin was not found.
PluginNotFound(path: PathBuf) {
description("No OpenVPN plugin found")
@@ -192,6 +202,12 @@ impl TunnelMonitor {
if let Some(config) = Self::get_config_path(resource_dir) {
cmd.config(config);
}
+ #[cfg(target_os = "linux")]
+ cmd.iproute_bin(
+ which::which("ip")
+ .compat()
+ .chain_err(|| ErrorKind::IpRouteNotFound)?,
+ );
cmd.remote(remote)
.user_pass(user_pass_file)
.tunnel_options(&options)