diff options
| author | Linus Färnstrand <linus@mullvad.net> | 2017-03-07 08:41:29 +0100 |
|---|---|---|
| committer | Linus Färnstrand <linus@mullvad.net> | 2017-03-07 08:41:29 +0100 |
| commit | f085642d25c2f91095ce01d324a59b5cee23e8b0 (patch) | |
| tree | 663b6c7e56f1e561ae90275746eb12d1387cbab3 /talpid_openvpn_plugin/src/processing.rs | |
| parent | 6fbf16b682fe6c399e5c7f5d5f4a8f96a5071093 (diff) | |
| parent | e878b14618f56b106f42df417582a7468f12c9b8 (diff) | |
| download | mullvadvpn-f085642d25c2f91095ce01d324a59b5cee23e8b0.tar.xz mullvadvpn-f085642d25c2f91095ce01d324a59b5cee23e8b0.zip | |
Merge branch 'openvpn-monitor'
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) } } |
