diff options
| author | Linus Färnstrand <linus@mullvad.net> | 2017-03-06 16:37:23 +0100 |
|---|---|---|
| committer | Linus Färnstrand <linus@mullvad.net> | 2017-03-07 07:20:24 +0100 |
| commit | 4917a64ac305bc157e3f78345c51b40d5ceea822 (patch) | |
| tree | f1eaa60ac25d55a64a998b4f316ffd343d4a542a /talpid_openvpn_plugin/src/processing.rs | |
| parent | 526c2e19e0e2acfd8a1945a916ab84dd652453de (diff) | |
| download | mullvadvpn-4917a64ac305bc157e3f78345c51b40d5ceea822.tar.xz mullvadvpn-4917a64ac305bc157e3f78345c51b40d5ceea822.zip | |
Add IPC capabilities to OpenVPN plugin
Diffstat (limited to 'talpid_openvpn_plugin/src/processing.rs')
| -rw-r--r-- | talpid_openvpn_plugin/src/processing.rs | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/talpid_openvpn_plugin/src/processing.rs b/talpid_openvpn_plugin/src/processing.rs index 337030744e..586d0574ec 100644 --- a/talpid_openvpn_plugin/src/processing.rs +++ b/talpid_openvpn_plugin/src/processing.rs @@ -1,24 +1,36 @@ - - use ffi::OpenVpnPluginEvent; + use std::collections::HashMap; +use talpid_ipc::{IpcClient, IpcServerId}; -error_chain!{} +error_chain! { + errors { + IpcSendingError { + description("Failed while sending an event over the IPC channel") + } + } +} /// Struct processing OpenVPN events and notifies listeners over IPC -pub struct EventProcessor; +pub struct EventProcessor { + ipc_client: IpcClient<HashMap<String, String>>, +} impl EventProcessor { - pub fn new() -> Result<EventProcessor> { + pub fn new(server_id: IpcServerId) -> Result<EventProcessor> { debug!("Creating EventProcessor"); - Ok(EventProcessor) + let ipc_client = IpcClient::new(server_id); + Ok(EventProcessor { ipc_client: ipc_client }) } - pub fn process_event(&mut self, event: OpenVpnPluginEvent, _env: HashMap<String, String>) { - // TODO(linus): This is where we should send events to core. - trace!("Hello from EventProcessor: {:?}", event); + pub fn process_event(&mut self, + event: OpenVpnPluginEvent, + env: HashMap<String, String>) + -> Result<()> { + trace!("Processing \"{:?}\" event", event); + self.ipc_client.send(&env).chain_err(|| ErrorKind::IpcSendingError) } } |
