summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--mullvad-rpc/Cargo.toml1
-rw-r--r--mullvad-rpc/src/lib.rs17
2 files changed, 18 insertions, 0 deletions
diff --git a/mullvad-rpc/Cargo.toml b/mullvad-rpc/Cargo.toml
index 41f7fccb2d..d49557cb96 100644
--- a/mullvad-rpc/Cargo.toml
+++ b/mullvad-rpc/Cargo.toml
@@ -9,5 +9,6 @@ license = "GPL-3.0"
chrono = { version = "0.4", features = ["serde"] }
jsonrpc-client-core = "0.2.1"
jsonrpc-client-http = "0.2.1"
+serde_json = "1.0"
mullvad-types = { path = "../mullvad-types" }
diff --git a/mullvad-rpc/src/lib.rs b/mullvad-rpc/src/lib.rs
index 9174f1e684..f0d32ad9ee 100644
--- a/mullvad-rpc/src/lib.rs
+++ b/mullvad-rpc/src/lib.rs
@@ -10,6 +10,7 @@ extern crate chrono;
#[macro_use]
extern crate jsonrpc_client_core;
extern crate jsonrpc_client_http;
+extern crate serde_json;
extern crate mullvad_types;
@@ -21,11 +22,16 @@ pub use jsonrpc_client_core::{Error, ErrorKind};
pub use jsonrpc_client_http::{Error as HttpError, HttpHandle};
use mullvad_types::account::AccountToken;
+use mullvad_types::relay_list::RelayList;
static MASTER_API_URI: &str = "https://api.mullvad.net/rpc/";
+pub fn connect() -> Result<HttpHandle, HttpError> {
+ HttpTransport::new()?.handle(MASTER_API_URI)
+}
+
jsonrpc_client!(pub struct AccountsProxy {
pub fn get_expiry(&mut self, account_token: AccountToken) -> RpcRequest<DateTime<Utc>>;
});
@@ -47,3 +53,14 @@ impl ProblemReportProxy<HttpHandle> {
Ok(ProblemReportProxy::new(transport))
}
}
+
+jsonrpc_client!(pub struct RelayListProxy {
+ pub fn relay_list(&mut self) -> RpcRequest<RelayList>;
+});
+
+impl RelayListProxy<HttpHandle> {
+ pub fn connect() -> Result<Self, HttpError> {
+ let transport = HttpTransport::new()?.handle(MASTER_API_URI)?;
+ Ok(RelayListProxy::new(transport))
+ }
+}