summaryrefslogtreecommitdiffhomepage
path: root/talpid-core
diff options
context:
space:
mode:
authorLinus Färnstrand <linus@mullvad.net>2017-07-20 08:26:19 +0200
committerLinus Färnstrand <linus@mullvad.net>2017-07-20 08:26:19 +0200
commite0b25ea79254932aa1bdfb58544ec3ecf5eaa083 (patch)
treeedc583f2c5ec3b85982e49ca6ff249af563a2faa /talpid-core
parent3ed79a04900596968495303e068b9e80ef73bbbe (diff)
parentfe0646dc2670bf8e9afa5dfcd408b37cc44843f4 (diff)
downloadmullvadvpn-e0b25ea79254932aa1bdfb58544ec3ecf5eaa083.tar.xz
mullvadvpn-e0b25ea79254932aa1bdfb58544ec3ecf5eaa083.zip
Merge branch 'new-openvpn-plugin-crate'
Diffstat (limited to 'talpid-core')
-rw-r--r--talpid-core/Cargo.toml2
-rw-r--r--talpid-core/src/lib.rs2
-rw-r--r--talpid-core/src/process/openvpn.rs2
-rw-r--r--talpid-core/src/tunnel/mod.rs2
-rw-r--r--talpid-core/src/tunnel/openvpn.rs18
5 files changed, 14 insertions, 12 deletions
diff --git a/talpid-core/Cargo.toml b/talpid-core/Cargo.toml
index 2be5457e26..96c30924e2 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.2", 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(())