diff options
Diffstat (limited to 'talpid-core/src')
| -rw-r--r-- | talpid-core/src/tunnel/mod.rs | 13 | ||||
| -rw-r--r-- | talpid-core/src/tunnel/openvpn.rs | 14 |
2 files changed, 12 insertions, 15 deletions
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); |
