diff options
| author | Linus Färnstrand <linus@mullvad.net> | 2017-11-16 12:30:13 +0100 |
|---|---|---|
| committer | Linus Färnstrand <linus@mullvad.net> | 2017-11-17 10:27:28 +0100 |
| commit | 8b52b4f4b0cee77aca6666fbf5a85cc7211916ed (patch) | |
| tree | 93772204f04844292ab59876775c6acb55e10bff | |
| parent | 73514e3194dfbafc246876d19b6d0bd8c802e9a6 (diff) | |
| download | mullvadvpn-8b52b4f4b0cee77aca6666fbf5a85cc7211916ed.tar.xz mullvadvpn-8b52b4f4b0cee77aca6666fbf5a85cc7211916ed.zip | |
Add separate command to list relays
| -rw-r--r-- | mullvad-daemon/Cargo.toml | 4 | ||||
| -rw-r--r-- | mullvad-daemon/src/bin/list-relays.rs | 29 |
2 files changed, 33 insertions, 0 deletions
diff --git a/mullvad-daemon/Cargo.toml b/mullvad-daemon/Cargo.toml index cb2f66d279..82ae9b021a 100644 --- a/mullvad-daemon/Cargo.toml +++ b/mullvad-daemon/Cargo.toml @@ -14,6 +14,10 @@ path = "src/main.rs" name = "problem-report" path = "src/bin/problem-report.rs" +[[bin]] +name = "list-relays" +path = "src/bin/list-relays.rs" + [dependencies] app_dirs = "1.1" chrono = { version = "0.4", features = ["serde"] } diff --git a/mullvad-daemon/src/bin/list-relays.rs b/mullvad-daemon/src/bin/list-relays.rs new file mode 100644 index 0000000000..2718c05396 --- /dev/null +++ b/mullvad-daemon/src/bin/list-relays.rs @@ -0,0 +1,29 @@ +//! # License +//! +//! Copyright (C) 2017 Amagicom AB +//! +//! This program is free software: you can redistribute it and/or modify it under the terms of the +//! GNU General Public License as published by the Free Software Foundation, either version 3 of +//! the License, or (at your option) any later version. + +#[macro_use] +extern crate error_chain; + +extern crate mullvad_rpc; +extern crate serde_json; + +error_chain!{} + +quick_main!(run); + +fn run() -> Result<()> { + let rpc_http_handle = mullvad_rpc::connect().chain_err(|| "Unable to connect RPC")?; + let mut client = mullvad_rpc::RelayListProxy::new(rpc_http_handle); + + let relays = client + .relay_list() + .call() + .chain_err(|| "Error during RPC call")?; + println!("{}", serde_json::to_string_pretty(&relays).unwrap()); + Ok(()) +} |
