diff options
| author | Linus Färnstrand <linus@mullvad.net> | 2017-07-18 20:22:04 +0200 |
|---|---|---|
| committer | Linus Färnstrand <linus@mullvad.net> | 2017-07-19 14:53:25 +0200 |
| commit | 3e9ae8364d20d83b57e25aa355e34c641acd6667 (patch) | |
| tree | aa4e07d20c6b34182fce4510162d52b3c9507bc1 | |
| parent | 5debb39be683a7b17efc0bae7066c82988576b99 (diff) | |
| download | mullvadvpn-3e9ae8364d20d83b57e25aa355e34c641acd6667.tar.xz mullvadvpn-3e9ae8364d20d83b57e25aa355e34c641acd6667.zip | |
Update talpid-core to use openvpn-plugin lib
| -rw-r--r-- | talpid-core/Cargo.toml | 2 | ||||
| -rw-r--r-- | talpid-core/src/lib.rs | 2 | ||||
| -rw-r--r-- | talpid-core/src/process/openvpn.rs | 2 | ||||
| -rw-r--r-- | talpid-core/src/tunnel/mod.rs | 2 | ||||
| -rw-r--r-- | talpid-core/src/tunnel/openvpn.rs | 18 |
5 files changed, 14 insertions, 12 deletions
diff --git a/talpid-core/Cargo.toml b/talpid-core/Cargo.toml index 2be5457e26..6c015af21f 100644 --- a/talpid-core/Cargo.toml +++ b/talpid-core/Cargo.toml @@ -13,7 +13,7 @@ lazy_static = "0.2" log = "0.3" mktemp = "0.3" -openvpn-ffi = { path = "../openvpn-ffi" } +openvpn-plugin = { version = "0.1", features = ["serialize"] } talpid-ipc = { path = "../talpid-ipc" } [target.'cfg(unix)'.dependencies] diff --git a/talpid-core/src/lib.rs b/talpid-core/src/lib.rs index 1fc92f8fe4..29ab0377e5 100644 --- a/talpid-core/src/lib.rs +++ b/talpid-core/src/lib.rs @@ -21,7 +21,7 @@ extern crate jsonrpc_core; extern crate jsonrpc_macros; extern crate talpid_ipc; -extern crate openvpn_ffi; +extern crate openvpn_plugin; /// Working with processes. pub mod process; diff --git a/talpid-core/src/process/openvpn.rs b/talpid-core/src/process/openvpn.rs index ea66ef894c..6b671b767c 100644 --- a/talpid-core/src/process/openvpn.rs +++ b/talpid-core/src/process/openvpn.rs @@ -1,5 +1,3 @@ -extern crate openvpn_ffi; - use duct; use net; diff --git a/talpid-core/src/tunnel/mod.rs b/talpid-core/src/tunnel/mod.rs index b05f1283f3..3835e26632 100644 --- a/talpid-core/src/tunnel/mod.rs +++ b/talpid-core/src/tunnel/mod.rs @@ -1,6 +1,6 @@ use mktemp; use net; -use openvpn_ffi::OpenVpnPluginEvent; +use openvpn_plugin::types::OpenVpnPluginEvent; use process::openvpn::OpenVpnCommand; use std::fs; use std::io::{self, Write}; diff --git a/talpid-core/src/tunnel/openvpn.rs b/talpid-core/src/tunnel/openvpn.rs index 08c2c14a32..f545a1d4d1 100644 --- a/talpid-core/src/tunnel/openvpn.rs +++ b/talpid-core/src/tunnel/openvpn.rs @@ -1,8 +1,9 @@ use duct; use jsonrpc_core::{Error, IoHandler}; -use openvpn_ffi::{OpenVpnEnv, OpenVpnPluginEvent}; +use openvpn_plugin::types::OpenVpnPluginEvent; use process::openvpn::OpenVpnCommand; +use std::collections::HashMap; use std::io; use std::path::Path; use std::result::Result as StdResult; @@ -47,7 +48,7 @@ impl OpenVpnMonitor { /// Creates a new `OpenVpnMonitor` with the given listener and using the plugin at the given /// path. pub fn new<L, P>(mut cmd: OpenVpnCommand, on_event: L, plugin_path: P) -> Result<Self> - where L: Fn(OpenVpnPluginEvent, OpenVpnEnv) + Send + Sync + 'static, + where L: Fn(OpenVpnPluginEvent, HashMap<String, String>) + Send + Sync + 'static, P: AsRef<Path> { let event_dispatcher = OpenVpnEventDispatcher::start(on_event) @@ -180,7 +181,7 @@ pub struct OpenVpnEventDispatcher { impl OpenVpnEventDispatcher { /// Construct and start the IPC server with the given event listener callback. pub fn start<L>(on_event: L) -> talpid_ipc::Result<Self> - where L: Fn(OpenVpnPluginEvent, OpenVpnEnv) + Send + Sync + 'static + where L: Fn(OpenVpnPluginEvent, HashMap<String, String>) + Send + Sync + 'static { let rpc = OpenVpnEventApiImpl { on_event }; let mut io = IoHandler::new(); @@ -215,7 +216,7 @@ mod api { #[rpc(name = "openvpn_event")] fn openvpn_event(&self, OpenVpnPluginEvent, - OpenVpnEnv) + HashMap<String, String>) -> StdResult<(), Error>; } } @@ -223,15 +224,18 @@ mod api { use self::api::*; struct OpenVpnEventApiImpl<L> - where L: Fn(OpenVpnPluginEvent, OpenVpnEnv) + Send + Sync + 'static + where L: Fn(OpenVpnPluginEvent, HashMap<String, String>) + Send + Sync + 'static { on_event: L, } impl<L> OpenVpnEventApi for OpenVpnEventApiImpl<L> - where L: Fn(OpenVpnPluginEvent, OpenVpnEnv) + Send + Sync + 'static + where L: Fn(OpenVpnPluginEvent, HashMap<String, String>) + Send + Sync + 'static { - fn openvpn_event(&self, event: OpenVpnPluginEvent, env: OpenVpnEnv) -> StdResult<(), Error> { + fn openvpn_event(&self, + event: OpenVpnPluginEvent, + env: HashMap<String, String>) + -> StdResult<(), Error> { debug!("OpenVPN event {:?}", event); (self.on_event)(event, env); Ok(()) |
