diff options
| author | Linus Färnstrand <linus@mullvad.net> | 2017-07-07 16:42:25 +0200 |
|---|---|---|
| committer | Linus Färnstrand <linus@mullvad.net> | 2017-07-10 09:53:14 +0200 |
| commit | d35120e6ab15ed5af350fcbbfcd0377d243eb626 (patch) | |
| tree | 4ca89a3ac89d1646376deba738d047f9fbcab98e | |
| parent | 5e82c3b62b7bac95e27f7c7782ceed6379537643 (diff) | |
| download | mullvadvpn-d35120e6ab15ed5af350fcbbfcd0377d243eb626.tar.xz mullvadvpn-d35120e6ab15ed5af350fcbbfcd0377d243eb626.zip | |
Move state structs to own crate for sharing
| -rw-r--r-- | Cargo.toml | 9 | ||||
| -rw-r--r-- | mullvad_daemon/Cargo.toml | 1 | ||||
| -rw-r--r-- | mullvad_daemon/src/main.rs | 4 | ||||
| -rw-r--r-- | mullvad_daemon/src/management_interface.rs | 2 | ||||
| -rw-r--r-- | mullvad_types/Cargo.toml | 8 | ||||
| -rw-r--r-- | mullvad_types/src/lib.rs | 5 | ||||
| -rw-r--r-- | mullvad_types/src/states.rs (renamed from mullvad_daemon/src/states.rs) | 6 |
7 files changed, 28 insertions, 7 deletions
diff --git a/Cargo.toml b/Cargo.toml index 2ade69a1d5..6968e96ade 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,2 +1,9 @@ [workspace] -members = ["mullvad_daemon", "mullvad_cli", "talpid_openvpn_plugin", "openvpn_ffi", "talpid_ipc"] +members = [ + "mullvad_daemon", + "mullvad_cli", + "mullvad_types", + "talpid_openvpn_plugin", + "openvpn_ffi", + "talpid_ipc" +] diff --git a/mullvad_daemon/Cargo.toml b/mullvad_daemon/Cargo.toml index 165ecfd735..73c9fe40dd 100644 --- a/mullvad_daemon/Cargo.toml +++ b/mullvad_daemon/Cargo.toml @@ -20,6 +20,7 @@ jsonrpc-ws-server = { git = "https://github.com/paritytech/jsonrpc" } uuid = { version = "0.5", features = ["v4"] } lazy_static = "0.2" +mullvad_types = { path = "../mullvad_types" } talpid_core = { path = "../talpid_core" } talpid_ipc = { path = "../talpid_ipc" } diff --git a/mullvad_daemon/src/main.rs b/mullvad_daemon/src/main.rs index 1b5ab91cdc..51bf264465 100644 --- a/mullvad_daemon/src/main.rs +++ b/mullvad_daemon/src/main.rs @@ -17,16 +17,16 @@ extern crate uuid; #[macro_use] extern crate lazy_static; +extern crate mullvad_types; extern crate talpid_core; extern crate talpid_ipc; mod management_interface; -mod states; mod rpc_info; mod shutdown; use management_interface::{ManagementInterfaceServer, TunnelCommand}; -use states::{DaemonState, SecurityState, TargetState}; +use mullvad_types::states::{DaemonState, SecurityState, TargetState}; use std::io; use std::sync::{Arc, Mutex, mpsc}; diff --git a/mullvad_daemon/src/management_interface.rs b/mullvad_daemon/src/management_interface.rs index 65e6e9b788..ffba3dca0f 100644 --- a/mullvad_daemon/src/management_interface.rs +++ b/mullvad_daemon/src/management_interface.rs @@ -5,9 +5,9 @@ use jsonrpc_core::futures::{BoxFuture, Future, future, sync}; use jsonrpc_macros::pubsub; use jsonrpc_pubsub::{PubSubHandler, PubSubMetadata, Session, SubscriptionId}; use jsonrpc_ws_server; +use mullvad_types::states::{DaemonState, TargetState}; use serde; -use states::{DaemonState, TargetState}; use std::collections::HashMap; use std::collections::hash_map::Entry; diff --git a/mullvad_types/Cargo.toml b/mullvad_types/Cargo.toml new file mode 100644 index 0000000000..0485cd1bc2 --- /dev/null +++ b/mullvad_types/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "mullvad_types" +version = "0.1.0" +authors = ["Linus Färnstrand <linus@mullvad.net>"] + +[dependencies] +serde_derive = "1.0" +serde = "1.0" diff --git a/mullvad_types/src/lib.rs b/mullvad_types/src/lib.rs new file mode 100644 index 0000000000..602a43cb29 --- /dev/null +++ b/mullvad_types/src/lib.rs @@ -0,0 +1,5 @@ +#[macro_use] +extern crate serde_derive; +extern crate serde; + +pub mod states; diff --git a/mullvad_daemon/src/states.rs b/mullvad_types/src/states.rs index eb7520d36c..e40ab94b0b 100644 --- a/mullvad_daemon/src/states.rs +++ b/mullvad_types/src/states.rs @@ -1,4 +1,4 @@ -#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash, Serialize)] +#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash, Serialize, Deserialize)] pub struct DaemonState { pub state: SecurityState, pub target_state: TargetState, @@ -10,7 +10,7 @@ pub struct DaemonState { /// but disconnected. The frontend should probably reflect these states in some way. I think it /// be reasonable to have three states, since unsecured but tunnel is up is probably an invalid /// state. -#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash, Serialize)] +#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash, Serialize, Deserialize)] #[serde(rename_all = "snake_case")] pub enum SecurityState { Unsecured, @@ -20,7 +20,7 @@ pub enum SecurityState { /// Represents the state the client strives towards. /// When in `Secured`, the client should keep the computer from leaking and try to /// establish a VPN tunnel if it is not up. -#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash, Serialize)] +#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash, Serialize, Deserialize)] #[serde(rename_all = "snake_case")] pub enum TargetState { Unsecured, |
