diff options
| author | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2018-04-24 09:50:23 -0300 |
|---|---|---|
| committer | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2018-05-07 08:55:03 -0300 |
| commit | 8052f549db7a568f72452c2c1d11939949a97440 (patch) | |
| tree | 0e03c2240db48d9e1834a3b7fb615fac388e3212 | |
| parent | 2a1acc9d0bf7d4bb0034ac954760490bb67dd7eb (diff) | |
| download | mullvadvpn-8052f549db7a568f72452c2c1d11939949a97440.tar.xz mullvadvpn-8052f549db7a568f72452c2c1d11939949a97440.zip | |
Request RPC authorization when connecting
| -rw-r--r-- | mullvad-ipc-client/src/lib.rs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/mullvad-ipc-client/src/lib.rs b/mullvad-ipc-client/src/lib.rs index 8123c66bb0..0105176fb6 100644 --- a/mullvad-ipc-client/src/lib.rs +++ b/mullvad-ipc-client/src/lib.rs @@ -24,6 +24,10 @@ pub use platform_specific::rpc_file_path; error_chain! { errors { + AuthenticationError { + description("Failed to authenticate the connection with the daemon") + } + EmptyRpcFile(file_path: String) { description("RPC connection file is empty") display("RPC connection file \"{}\" is empty", file_path) @@ -77,8 +81,13 @@ impl DaemonRpcClient { let (address, credentials) = Self::read_rpc_file()?; let rpc_client = WsIpcClient::connect(&address).chain_err(|| ErrorKind::StartRpcClient(address))?; + let mut instance = DaemonRpcClient { rpc_client }; + + instance + .auth(&credentials) + .chain_err(|| ErrorKind::AuthenticationError)?; - Ok(DaemonRpcClient { rpc_client }) + Ok(instance) } fn read_rpc_file() -> Result<(String, String)> { |
