summaryrefslogtreecommitdiffhomepage
path: root/talpid-openvpn-plugin/src/processing.rs
diff options
context:
space:
mode:
authorJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2018-06-08 18:09:12 -0300
committerJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2018-06-13 14:14:03 -0300
commitd0b96e7ae2c61acbb276443757d53df2eb574158 (patch)
treec4965227e1f88de7760e7bddbe1a46bac8a62787 /talpid-openvpn-plugin/src/processing.rs
parent862fd66f12e05cf4f83622aa5366bcedfa98613a (diff)
downloadmullvadvpn-d0b96e7ae2c61acbb276443757d53df2eb574158.tar.xz
mullvadvpn-d0b96e7ae2c61acbb276443757d53df2eb574158.zip
Update plugin to authenticate with IPC server
Diffstat (limited to 'talpid-openvpn-plugin/src/processing.rs')
-rw-r--r--talpid-openvpn-plugin/src/processing.rs21
1 files changed, 17 insertions, 4 deletions
diff --git a/talpid-openvpn-plugin/src/processing.rs b/talpid-openvpn-plugin/src/processing.rs
index a376665888..cadaf80647 100644
--- a/talpid-openvpn-plugin/src/processing.rs
+++ b/talpid-openvpn-plugin/src/processing.rs
@@ -1,10 +1,15 @@
use openvpn_plugin;
use std::collections::HashMap;
use std::sync::Mutex;
-use talpid_ipc::{IpcServerId, WsIpcClient};
+use talpid_ipc::WsIpcClient;
+
+use super::Arguments;
error_chain! {
errors {
+ AuthDenied {
+ description("Authentication failed with Talpid Core IPC server")
+ }
IpcSendingError {
description("Failed while sending an event over the IPC channel")
}
@@ -18,10 +23,18 @@ pub struct EventProcessor {
}
impl EventProcessor {
- pub fn new(server_id: &IpcServerId) -> Result<EventProcessor> {
+ pub fn new(arguments: &Arguments) -> Result<EventProcessor> {
trace!("Creating EventProcessor");
- let ipc_client =
- WsIpcClient::connect(server_id).chain_err(|| "Unable to create IPC client")?;
+ let mut ipc_client =
+ WsIpcClient::connect(&arguments.server_id).chain_err(|| "Unable to create IPC client")?;
+
+ trace!("Authenticating EventProcessor");
+ match ipc_client.call("authenticate", &[&arguments.credentials]) {
+ Ok(true) => trace!("Credentials accepted"),
+ Ok(false) => bail!(ErrorKind::AuthDenied),
+ Err(error) => bail!(Error::with_chain(error, ErrorKind::AuthDenied)),
+ }
+
Ok(EventProcessor {
ipc_client: Mutex::new(ipc_client),
})