diff options
| author | Linus Färnstrand <linus@mullvad.net> | 2017-03-06 19:58:46 +0100 |
|---|---|---|
| committer | Linus Färnstrand <linus@mullvad.net> | 2017-03-07 08:46:23 +0100 |
| commit | 370e68a447c788c026ab573db7eb932735ff2554 (patch) | |
| tree | 8c99ee6a233d8ee12f803563c6a03c44bfb3b592 | |
| parent | 14fc5c2740687465e41960dc73e201ba71068840 (diff) | |
| download | mullvadvpn-370e68a447c788c026ab573db7eb932735ff2554.tar.xz mullvadvpn-370e68a447c788c026ab573db7eb932735ff2554.zip | |
Add event to what is sent from plugin
| -rw-r--r-- | Cargo.toml | 3 | ||||
| -rw-r--r-- | src/process/openvpn.rs | 4 | ||||
| -rw-r--r-- | talpid_cli/src/main.rs | 7 | ||||
| -rw-r--r-- | talpid_openvpn_plugin/src/processing.rs | 4 |
4 files changed, 13 insertions, 5 deletions
diff --git a/Cargo.toml b/Cargo.toml index c47e370320..a2271237ab 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,6 +11,9 @@ error-chain = "0.8" [dependencies.talpid_ipc] path = "talpid_ipc" +[dependencies.openvpn_ffi] +path = "openvpn_ffi" + [target.'cfg(not(windows))'.dependencies] zmq = "0.8" diff --git a/src/process/openvpn.rs b/src/process/openvpn.rs index 2d25deb965..b533b32b67 100644 --- a/src/process/openvpn.rs +++ b/src/process/openvpn.rs @@ -1,3 +1,5 @@ +extern crate openvpn_ffi; + use super::monitor::{ChildSpawner, ChildMonitor}; use clonablechild::{ClonableChild, ChildExt}; @@ -160,7 +162,7 @@ impl ChildSpawner for OpenVpnCommand { /// Possible events from OpenVPN pub enum OpenVpnEvent { /// An event from the plugin loaded into OpenVPN. - PluginEvent(Result<HashMap<String, String>>), + PluginEvent(Result<(openvpn_ffi::OpenVpnPluginEvent, HashMap<String, String>)>), /// The OpenVPN process exited. The bool indicates if the process exited cleanly. Shutdown(bool), } diff --git a/talpid_cli/src/main.rs b/talpid_cli/src/main.rs index b6ce7654ff..f31be12e77 100644 --- a/talpid_cli/src/main.rs +++ b/talpid_cli/src/main.rs @@ -64,8 +64,11 @@ fn main_loop(mut monitor: OpenVpnMonitor) -> Result<()> { println!("Monitored process exited. clean: {}", clean); break; } - OpenVpnEvent::PluginEvent(env) => { - println!("OpenVPN event with env:\n{:?}", env); + OpenVpnEvent::PluginEvent(Ok((event, env))) => { + println!("OpenVPN event:\nEvent: {:?}\nENV: {:?}", event, env); + } + OpenVpnEvent::PluginEvent(Err(e)) => { + println!("Read error from plugin: {:?}", e) } } } diff --git a/talpid_openvpn_plugin/src/processing.rs b/talpid_openvpn_plugin/src/processing.rs index 68bab3b99c..b1f1b97abc 100644 --- a/talpid_openvpn_plugin/src/processing.rs +++ b/talpid_openvpn_plugin/src/processing.rs @@ -16,7 +16,7 @@ error_chain! { /// Struct processing OpenVPN events and notifies listeners over IPC pub struct EventProcessor { - ipc_client: IpcClient<HashMap<String, String>>, + ipc_client: IpcClient<(openvpn_ffi::OpenVpnPluginEvent, HashMap<String, String>)>, } impl EventProcessor { @@ -31,7 +31,7 @@ impl EventProcessor { env: HashMap<String, String>) -> Result<()> { trace!("Processing \"{:?}\" event", event); - self.ipc_client.send(&env).chain_err(|| ErrorKind::IpcSendingError) + self.ipc_client.send(&(event, env)).chain_err(|| ErrorKind::IpcSendingError) } } |
