summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock30
-rw-r--r--mullvad-tests/Cargo.toml2
-rw-r--r--mullvad-tests/src/lib.rs7
-rw-r--r--talpid-core/src/tunnel/mod.rs13
-rw-r--r--talpid-core/src/tunnel/openvpn.rs14
-rw-r--r--talpid-openvpn-plugin/src/lib.rs17
-rw-r--r--talpid-openvpn-plugin/src/processing.rs4
7 files changed, 41 insertions, 46 deletions
diff --git a/Cargo.lock b/Cargo.lock
index c4f99b1a54..99c55c6dda 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -220,6 +220,15 @@ dependencies = [
]
[[package]]
+name = "derive-try-from-primitive"
+version = "0.1.0"
+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 = "derive_builder"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1029,7 +1038,7 @@ dependencies = [
"mullvad-ipc-client 0.1.0",
"mullvad-paths 0.1.0",
"notify 4.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
- "openvpn-plugin 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "openvpn-plugin 0.3.0 (git+https://github.com/mullvad/openvpn-plugin-rs?branch=auth-failed-event)",
"talpid-ipc 0.1.0",
"talpid-types 0.1.0",
"tempfile 3.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1174,17 +1183,10 @@ dependencies = [
[[package]]
name = "openvpn-plugin"
version = "0.3.0"
-source = "git+https://github.com/mullvad/openvpn-plugin-rs?branch=auth-failed-event#6e2586030d6c8fb0e39d88769677a4085a1dd121"
-dependencies = [
- "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
- "serde 1.0.71 (registry+https://github.com/rust-lang/crates.io-index)",
-]
-
-[[package]]
-name = "openvpn-plugin"
-version = "0.3.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
+source = "git+https://github.com/mullvad/openvpn-plugin-rs?branch=auth-failed-event#bb82d84f7a464b2d7313cc7521bc6e6048409f94"
dependencies = [
+ "derive-try-from-primitive 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.71 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -1221,7 +1223,7 @@ source = "git+https://github.com/nikvolf/parity-tokio-ipc#306ea3e6ff8b8c1bb03081
dependencies = [
"bytes 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.23 (registry+https://github.com/rust-lang/crates.io-index)",
- "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
+ "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"mio-named-pipes 0.1.6 (git+https://github.com/alexcrichton/mio-named-pipes)",
"miow 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1238,7 +1240,7 @@ source = "git+https://github.com/NikVolf/parity-tokio-ipc?rev=master#306ea3e6ff8
dependencies = [
"bytes 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.23 (registry+https://github.com/rust-lang/crates.io-index)",
- "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
+ "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"mio-named-pipes 0.1.6 (git+https://github.com/alexcrichton/mio-named-pipes)",
"miow 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2206,6 +2208,7 @@ dependencies = [
"checksum crossbeam-utils 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d636a8b3bcc1b409d7ffd3facef8f21dcb4009626adbd0c5e6c4305c07253c7b"
"checksum ctrlc 3.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "630391922b1b893692c6334369ff528dcc3a9d8061ccf4c803aa8f83cb13db5e"
"checksum dbus 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3e34c238dfb3f5881d46ad301403cd8f8ecf946e2a4e89bdd1166728b68b5008"
+"checksum derive-try-from-primitive 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "81dbd65eb15734b6d50dc6ac86f14f928462be0a5df6bda17761e909071ede5d"
"checksum derive_builder 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c998e6ab02a828dd9735c18f154e14100e674ed08cb4e1938f0e4177543f439"
"checksum derive_builder_core 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "735e24ee9e5fa8e16b86da5007856e97d592e11867e45d76e0c0d0a164a0b757"
"checksum dirs 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "37a76dd8b997af7107d0bb69d43903cf37153a18266f8b3fdb9911f28efb5444"
@@ -2290,7 +2293,6 @@ dependencies = [
"checksum openssl 0.10.11 (registry+https://github.com/rust-lang/crates.io-index)" = "6c24d3508b4fb6da175c10baac54c578b33f09c89ae90c6fe9788b3b4768efdc"
"checksum openssl-sys 0.9.35 (registry+https://github.com/rust-lang/crates.io-index)" = "912f301a749394e1025d9dcddef6106ddee9252620e6d0a0e5f8d0681de9b129"
"checksum openvpn-plugin 0.3.0 (git+https://github.com/mullvad/openvpn-plugin-rs?branch=auth-failed-event)" = "<none>"
-"checksum openvpn-plugin 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f01f94fa077e8648fa20c654f6aef90e1a0feae5455a7b5d80c19eadeb97c7e8"
"checksum os_pipe 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "fe033225d563042c3eeb22ffd1d2ea1aefcc48e7e37151a064c9e0bae64b253f"
"checksum os_pipe 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cd9d339267cdef39ee54ef165fdfaa2c7289a7465f0188ebe1c8a63872ca64c7"
"checksum owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cdf84f41639e037b484f93433aa3897863b561ed65c6e59c7073d7c561710f37"
diff --git a/mullvad-tests/Cargo.toml b/mullvad-tests/Cargo.toml
index 228d81b342..eb1e67553b 100644
--- a/mullvad-tests/Cargo.toml
+++ b/mullvad-tests/Cargo.toml
@@ -13,7 +13,7 @@ duct = "0.11"
mullvad-ipc-client = { path = "../mullvad-ipc-client" }
mullvad-paths = { path = "../mullvad-paths" }
notify = "4.0"
-openvpn-plugin = { version = "0.3", features = ["serde"] }
+openvpn-plugin = { git = "https://github.com/mullvad/openvpn-plugin-rs", branch = "auth-failed-event", features = ["serde"] }
talpid-ipc = { path = "../talpid-ipc" }
talpid-types = { path = "../talpid-types" }
tempfile = "3.0"
diff --git a/mullvad-tests/src/lib.rs b/mullvad-tests/src/lib.rs
index d8dd46a243..a8e291a5fd 100644
--- a/mullvad-tests/src/lib.rs
+++ b/mullvad-tests/src/lib.rs
@@ -28,7 +28,6 @@ use jsonrpc_client_ipc::IpcTransport;
use mullvad_ipc_client::{DaemonRpcClient, ResultExt};
use mullvad_paths::resources::API_CA_FILENAME;
use notify::{RawEvent, RecommendedWatcher, RecursiveMode, Watcher};
-use openvpn_plugin::types::OpenVpnPluginEvent;
use tempfile::TempDir;
use tokio::reactor::Handle;
@@ -410,16 +409,16 @@ impl MockOpenVpnPluginRpcClient {
env.insert("ifconfig_local".to_owned(), "10.0.0.10".to_owned());
env.insert("route_vpn_gateway".to_owned(), "10.0.0.1".to_owned());
- self.send_event(OpenVpnPluginEvent::Up, env)
+ self.send_event(openvpn_plugin::EventType::Up, env)
}
pub fn route_predown(&mut self) -> Result<()> {
- self.send_event(OpenVpnPluginEvent::RoutePredown, HashMap::new())
+ self.send_event(openvpn_plugin::EventType::RoutePredown, HashMap::new())
}
fn send_event(
&mut self,
- event: OpenVpnPluginEvent,
+ event: openvpn_plugin::EventType,
env: HashMap<String, String>,
) -> Result<()> {
self.rpc
diff --git a/talpid-core/src/tunnel/mod.rs b/talpid-core/src/tunnel/mod.rs
index beb6b78116..329144b34b 100644
--- a/talpid-core/src/tunnel/mod.rs
+++ b/talpid-core/src/tunnel/mod.rs
@@ -1,5 +1,4 @@
use mktemp;
-use openvpn_plugin::types::OpenVpnPluginEvent;
use process::openvpn::OpenVpnCommand;
use std::collections::HashMap;
@@ -100,18 +99,18 @@ pub struct TunnelMetadata {
}
impl TunnelEvent {
- /// Converts an `OpenVpnPluginEvent` to a `TunnelEvent`.
+ /// Converts an `openvpn_plugin::EventType` to a `TunnelEvent`.
/// Returns `None` if there is no corresponding `TunnelEvent`.
fn from_openvpn_event(
- event: OpenVpnPluginEvent,
+ event: openvpn_plugin::EventType,
env: &HashMap<String, String>,
) -> Option<TunnelEvent> {
match event {
- OpenVpnPluginEvent::AuthFailed => {
+ openvpn_plugin::EventType::AuthFailed => {
let reason = env.get("auth_failed_reason").cloned();
Some(TunnelEvent::AuthFailed(reason))
}
- OpenVpnPluginEvent::Up => {
+ openvpn_plugin::EventType::Up => {
let interface = env
.get("dev")
.expect("No \"dev\" in tunnel up event")
@@ -132,7 +131,7 @@ impl TunnelEvent {
gateway,
}))
}
- OpenVpnPluginEvent::RoutePredown => Some(TunnelEvent::Down),
+ openvpn_plugin::EventType::RoutePredown => Some(TunnelEvent::Down),
_ => None,
}
}
@@ -193,7 +192,7 @@ impl TunnelMonitor {
};
let on_openvpn_event = move |event, env| {
- if event == OpenVpnPluginEvent::Up {
+ if event == openvpn_plugin::EventType::Up {
// The user-pass file has been read. Try to delete it early.
let _ = fs::remove_file(&user_pass_file_path);
diff --git a/talpid-core/src/tunnel/openvpn.rs b/talpid-core/src/tunnel/openvpn.rs
index ea2d2d5823..15953c580c 100644
--- a/talpid-core/src/tunnel/openvpn.rs
+++ b/talpid-core/src/tunnel/openvpn.rs
@@ -1,4 +1,3 @@
-use openvpn_plugin::types::OpenVpnPluginEvent;
use process::openvpn::{OpenVpnCommand, OpenVpnProcHandle};
use process::stoppable_process::StoppableProcess;
@@ -46,7 +45,7 @@ impl OpenVpnMonitor<OpenVpnCommand> {
/// path.
pub fn start<L, P>(cmd: OpenVpnCommand, on_event: L, plugin_path: P) -> Result<Self>
where
- L: Fn(OpenVpnPluginEvent, HashMap<String, String>) + Send + Sync + 'static,
+ L: Fn(openvpn_plugin::EventType, HashMap<String, String>) + Send + Sync + 'static,
P: AsRef<Path>,
{
Self::new_internal(cmd, on_event, plugin_path)
@@ -56,7 +55,7 @@ impl OpenVpnMonitor<OpenVpnCommand> {
impl<C: OpenVpnBuilder> OpenVpnMonitor<C> {
fn new_internal<L, P>(mut cmd: C, on_event: L, plugin_path: P) -> Result<OpenVpnMonitor<C>>
where
- L: Fn(OpenVpnPluginEvent, HashMap<String, String>) + Send + Sync + 'static,
+ L: Fn(openvpn_plugin::EventType, HashMap<String, String>) + Send + Sync + 'static,
P: AsRef<Path>,
{
let event_dispatcher =
@@ -212,7 +211,6 @@ impl ProcessHandle for OpenVpnProcHandle {
mod event_server {
- use super::OpenVpnPluginEvent;
use jsonrpc_core::{Error, IoHandler, MetaIoHandler};
use jsonrpc_macros::build_rpc_trait;
use std::collections::HashMap;
@@ -222,7 +220,7 @@ mod event_server {
/// Construct and start the IPC server with the given event listener callback.
pub fn start<L>(on_event: L) -> talpid_ipc::Result<talpid_ipc::IpcServer>
where
- L: Fn(OpenVpnPluginEvent, HashMap<String, String>) + Send + Sync + 'static,
+ L: Fn(openvpn_plugin::EventType, HashMap<String, String>) + Send + Sync + 'static,
{
let uuid = uuid::Uuid::new_v4().to_string();
let ipc_path = if cfg!(windows) {
@@ -241,7 +239,7 @@ mod event_server {
pub trait OpenVpnEventApi {
#[rpc(name = "openvpn_event")]
- fn openvpn_event(&self, OpenVpnPluginEvent, HashMap<String, String>)
+ fn openvpn_event(&self, openvpn_plugin::EventType, HashMap<String, String>)
-> Result<(), Error>;
}
}
@@ -252,11 +250,11 @@ mod event_server {
impl<L> OpenVpnEventApi for OpenVpnEventApiImpl<L>
where
- L: Fn(OpenVpnPluginEvent, HashMap<String, String>) + Send + Sync + 'static,
+ L: Fn(openvpn_plugin::EventType, HashMap<String, String>) + Send + Sync + 'static,
{
fn openvpn_event(
&self,
- event: OpenVpnPluginEvent,
+ event: openvpn_plugin::EventType,
env: HashMap<String, String>,
) -> Result<(), Error> {
log::trace!("OpenVPN event {:?}", event);
diff --git a/talpid-openvpn-plugin/src/lib.rs b/talpid-openvpn-plugin/src/lib.rs
index db0e3bf41c..7df83b457f 100644
--- a/talpid-openvpn-plugin/src/lib.rs
+++ b/talpid-openvpn-plugin/src/lib.rs
@@ -19,10 +19,7 @@ extern crate tokio;
extern crate tokio_reactor;
use error_chain::ChainedError;
-use openvpn_plugin::{
- openvpn_plugin,
- types::{EventResult, OpenVpnPluginEvent},
-};
+use openvpn_plugin::{openvpn_plugin, EventResult, EventType};
use std::collections::HashMap;
use std::ffi::CString;
use std::sync::Mutex;
@@ -55,10 +52,10 @@ error_chain!{
/// All the OpenVPN events this plugin will register for listening to. Edit this variable to change
/// events.
-pub static INTERESTING_EVENTS: &'static [OpenVpnPluginEvent] = &[
- OpenVpnPluginEvent::AuthFailed,
- OpenVpnPluginEvent::Up,
- OpenVpnPluginEvent::RoutePredown,
+pub static INTERESTING_EVENTS: &'static [EventType] = &[
+ EventType::AuthFailed,
+ EventType::Up,
+ EventType::RoutePredown,
];
openvpn_plugin!(
@@ -75,7 +72,7 @@ pub struct Arguments {
fn openvpn_open(
args: Vec<CString>,
_env: HashMap<CString, CString>,
-) -> Result<(Vec<OpenVpnPluginEvent>, Mutex<EventProcessor>)> {
+) -> Result<(Vec<EventType>, Mutex<EventProcessor>)> {
env_logger::init();
log::debug!("Initializing plugin");
@@ -108,7 +105,7 @@ fn openvpn_close(_handle: Mutex<EventProcessor>) {
}
fn openvpn_event(
- event: OpenVpnPluginEvent,
+ event: EventType,
_args: Vec<CString>,
env: HashMap<CString, CString>,
handle: &mut Mutex<EventProcessor>,
diff --git a/talpid-openvpn-plugin/src/processing.rs b/talpid-openvpn-plugin/src/processing.rs
index 5ac6bed8d3..900340820c 100644
--- a/talpid-openvpn-plugin/src/processing.rs
+++ b/talpid-openvpn-plugin/src/processing.rs
@@ -62,7 +62,7 @@ impl EventProcessor {
pub fn process_event(
&mut self,
- event: openvpn_plugin::types::OpenVpnPluginEvent,
+ event: openvpn_plugin::EventType,
env: HashMap<String, String>,
) -> Result<()> {
log::trace!("Processing \"{:?}\" event", event);
@@ -86,5 +86,5 @@ impl EventProcessor {
}
jsonrpc_client!(pub struct EventProxy {
- pub fn openvpn_event(&mut self, event: openvpn_plugin::types::OpenVpnPluginEvent, env: HashMap<String, String>) -> Future<()>;
+ pub fn openvpn_event(&mut self, event: openvpn_plugin::EventType, env: HashMap<String, String>) -> Future<()>;
});