diff options
| author | Emīls Piņķis <emils@mullvad.net> | 2019-02-22 11:10:58 +0000 |
|---|---|---|
| committer | Emīls Piņķis <emils@mullvad.net> | 2019-02-27 14:33:05 +0000 |
| commit | 93068c10e225f90ce646f50514e87a8bd098eed5 (patch) | |
| tree | edd767718b935c256b1e1b782a7a9d8f0f3996bd | |
| parent | 82e758726128fa9e088c968764413c70098a65b3 (diff) | |
| download | mullvadvpn-93068c10e225f90ce646f50514e87a8bd098eed5.tar.xz mullvadvpn-93068c10e225f90ce646f50514e87a8bd098eed5.zip | |
Add wireguard key management RPCs
| -rw-r--r-- | mullvad-rpc/Cargo.toml | 1 | ||||
| -rw-r--r-- | mullvad-rpc/src/lib.rs | 14 | ||||
| -rw-r--r-- | mullvad-types/Cargo.toml | 1 | ||||
| -rw-r--r-- | mullvad-types/src/lib.rs | 1 | ||||
| -rw-r--r-- | mullvad-types/src/wireguard.rs | 17 |
5 files changed, 34 insertions, 0 deletions
diff --git a/mullvad-rpc/Cargo.toml b/mullvad-rpc/Cargo.toml index ff9596d10f..2f21283c58 100644 --- a/mullvad-rpc/Cargo.toml +++ b/mullvad-rpc/Cargo.toml @@ -22,6 +22,7 @@ tokio-openssl = "0.2" log = "0.4" mullvad-types = { path = "../mullvad-types" } +talpid-types = { path = "../talpid-types" } [dev-dependencies] filetime = "0.1" diff --git a/mullvad-rpc/src/lib.rs b/mullvad-rpc/src/lib.rs index 93962dbdba..cde2de539c 100644 --- a/mullvad-rpc/src/lib.rs +++ b/mullvad-rpc/src/lib.rs @@ -21,6 +21,7 @@ use std::{ path::{Path, PathBuf}, time::Duration, }; +use talpid_types::net::wireguard; use tokio_core::reactor::Handle; pub use jsonrpc_client_core::{Error, ErrorKind}; @@ -129,3 +130,16 @@ jsonrpc_client!(pub struct AppVersionProxy { pub fn latest_app_version(&mut self) -> RpcRequest<version::LatestReleases>; pub fn is_app_version_supported(&mut self, version: &version::AppVersion) -> RpcRequest<bool>; }); + +jsonrpc_client!(pub struct WireguardKeyProxy { + pub fn push_wg_key( + &mut self, + account_token: AccountToken, + public_key: wireguard::PublicKey + ) -> RpcRequest<mullvad_types::wireguard::AssociatedAddresses>; + pub fn check_wg_key( + &mut self, + account_token: AccountToken, + public_key: wireguard::PublicKey + ) -> RpcRequest<bool>; +}); diff --git a/mullvad-types/Cargo.toml b/mullvad-types/Cargo.toml index 8239696b9b..27c59acc0f 100644 --- a/mullvad-types/Cargo.toml +++ b/mullvad-types/Cargo.toml @@ -11,6 +11,7 @@ chrono = { version = "0.4", features = ["serde"] } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" error-chain = "0.12" +ipnetwork = { git = "https://github.com/mullvad/ipnetwork", branch = "fix-deserialization" } log = "0.4" regex = "1" lazy_static = "1.1.0" diff --git a/mullvad-types/src/lib.rs b/mullvad-types/src/lib.rs index 11e6ac4005..b2659911e4 100644 --- a/mullvad-types/src/lib.rs +++ b/mullvad-types/src/lib.rs @@ -18,6 +18,7 @@ pub mod relay_list; pub mod settings; pub mod states; pub mod version; +pub mod wireguard; mod custom_tunnel; pub use crate::custom_tunnel::*; diff --git a/mullvad-types/src/wireguard.rs b/mullvad-types/src/wireguard.rs new file mode 100644 index 0000000000..5fc0846557 --- /dev/null +++ b/mullvad-types/src/wireguard.rs @@ -0,0 +1,17 @@ +use serde::{Deserialize, Serialize}; +use talpid_types::net::wireguard; + +/// Contains account specific wireguard data +#[derive(Serialize, Deserialize, Clone, Debug)] +pub struct WireguardData { + pub private_key: wireguard::PrivateKey, + pub addresses: AssociatedAddresses, +} + +/// Contains a pair of local link addresses that are paired with a specific wireguard +/// public/private keypair. +#[derive(Clone, Debug, Deserialize, Serialize)] +pub struct AssociatedAddresses { + pub ipv4_address: ipnetwork::Ipv4Network, + pub ipv6_address: ipnetwork::Ipv6Network, +} |
