diff options
| -rw-r--r-- | Cargo.toml | 2 | ||||
| -rw-r--r-- | src/ipc/mod.rs | 10 | ||||
| -rw-r--r-- | src/ipc/nop_ipc.rs | 17 | ||||
| -rw-r--r-- | src/ipc/zmq_ipc.rs (renamed from src/ipc/zmq.rs) | 5 | ||||
| -rw-r--r-- | src/lib.rs | 2 |
5 files changed, 31 insertions, 5 deletions
diff --git a/Cargo.toml b/Cargo.toml index 1b94b63880..f7c00b584b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,6 +7,8 @@ description = "Core backend functionality of the Mullvad VPN client" [dependencies] clonablechild = "0.1" error-chain = "0.8" + +[target.'cfg(not(windows))'.dependencies] zmq = "0.8" [target.'cfg(not(windows))'.dependencies] diff --git a/src/ipc/mod.rs b/src/ipc/mod.rs index 26485f8260..afb140f4c6 100644 --- a/src/ipc/mod.rs +++ b/src/ipc/mod.rs @@ -1,4 +1,12 @@ -pub mod zmq; +#[cfg(windows)] +#[path = "nop_ipc.rs"] +mod ipc_impl; + +#[cfg(not(windows))] +#[path = "zmq_ipc.rs"] +mod ipc_impl; + +pub use self::ipc_impl::*; /// The type signature for functions accepting messages from the server. /// If the server fails in delivering the message for any reason it will diff --git a/src/ipc/nop_ipc.rs b/src/ipc/nop_ipc.rs new file mode 100644 index 0000000000..78860cab95 --- /dev/null +++ b/src/ipc/nop_ipc.rs @@ -0,0 +1,17 @@ +/// This file only exists because we cannot get ZeroMQ to work on +/// Windows. This is not a valid IPC implementation and us using +/// it on Windows will result in a non-functioning client. +/// +/// We plan on trying with ZMQ again in the future. +/// Erik, 2017-02-09 + +use ipc::{IpcServer, OnMessage, ErrorKind, Result}; + +pub struct NopIpcServer; +impl IpcServer for NopIpcServer { + type MessageType = String; + + fn start(self, _port: u16, _on_message: Box<OnMessage<Self::MessageType>>) -> Result<()> { + Err(ErrorKind::CouldNotStartServer.into()) + } +} diff --git a/src/ipc/zmq.rs b/src/ipc/zmq_ipc.rs index 90492c159d..0dcc8d96ae 100644 --- a/src/ipc/zmq.rs +++ b/src/ipc/zmq_ipc.rs @@ -1,6 +1,7 @@ +extern crate zmq; + use ipc::{IpcServer, OnMessage, ErrorKind, Result, ResultExt}; use std::thread; -use zmq; /// The signature of functions that can be used to parse the incoming data /// This is very very similar to `TryFrom` on purpose because I wanted `TryFrom`, @@ -66,7 +67,7 @@ mod tests { use std::result; use std::sync::mpsc::{self, Receiver}; use std::time::Duration; - use zmq; + extern crate zmq; const A_VALID_MESSAGE: u8 = 1; const AN_INVALID_MESSAGE: u8 = 2; diff --git a/src/lib.rs b/src/lib.rs index 6da4b115a1..1aa8b8d5f1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -11,8 +11,6 @@ extern crate clonablechild; #[macro_use] extern crate error_chain; -extern crate zmq; - /// Working with processes. pub mod process; |
