summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorLinus Färnstrand <linus@mullvad.net>2018-01-08 13:22:44 +0100
committerLinus Färnstrand <linus@mullvad.net>2018-01-09 15:18:29 +0100
commit541091d650588338345747c1df3e27bec341af54 (patch)
treec0ffb9a52012e6504bb4dbf6da69685fb5139ca9
parent8fe451fbd58d2e36b0460238a97b084f1d02d0fb (diff)
downloadmullvadvpn-541091d650588338345747c1df3e27bec341af54.tar.xz
mullvadvpn-541091d650588338345747c1df3e27bec341af54.zip
Add metadata in problem report RPC call
-rw-r--r--mullvad-daemon/src/bin/problem-report.rs26
-rw-r--r--mullvad-rpc/src/lib.rs10
2 files changed, 23 insertions, 13 deletions
diff --git a/mullvad-daemon/src/bin/problem-report.rs b/mullvad-daemon/src/bin/problem-report.rs
index 8a1a2770f2..344738b0c1 100644
--- a/mullvad-daemon/src/bin/problem-report.rs
+++ b/mullvad-daemon/src/bin/problem-report.rs
@@ -18,6 +18,7 @@ use error_chain::ChainedError;
use regex::Regex;
use std::cmp::min;
+use std::collections::HashMap;
use std::env;
use std::fmt;
use std::fs::File;
@@ -154,10 +155,11 @@ fn collect_report(
fn send_problem_report(user_email: &str, user_message: &str, report_path: &Path) -> Result<()> {
let report_content = read_file_lossy(report_path, REPORT_MAX_SIZE)
.chain_err(|| ErrorKind::ReadLogError(report_path.to_path_buf()))?;
+ let metadata = collect_metadata();
let mut rpc_client =
mullvad_rpc::ProblemReportProxy::connect().chain_err(|| ErrorKind::RpcError)?;
rpc_client
- .problem_report(user_email, user_message, &report_content)
+ .problem_report(user_email, user_message, &report_content, &metadata)
.call()
.chain_err(|| ErrorKind::RpcError)
}
@@ -174,7 +176,7 @@ fn write_problem_report(path: &Path, problem_report: ProblemReport) -> io::Resul
#[derive(Debug)]
struct ProblemReport {
- system_info: Vec<String>,
+ metadata: HashMap<String, String>,
logs: Vec<(String, String)>,
redact_custom_strings: Vec<String>,
}
@@ -184,19 +186,12 @@ impl ProblemReport {
/// Logs will have all strings in `redact_custom_strings` removed from them.
pub fn new(redact_custom_strings: Vec<String>) -> Self {
ProblemReport {
- system_info: Self::collect_system_info(),
+ metadata: collect_metadata(),
logs: Vec::new(),
redact_custom_strings,
}
}
- fn collect_system_info() -> Vec<String> {
- vec![
- format!("Mullvad daemon: {}", daemon_version()),
- format!("OS: {}", os_version()),
- ]
- }
-
/// Attach file log to this report. This method uses the error chain instead of log
/// contents if error occurred when reading log file.
pub fn add_log(&mut self, path: &Path) {
@@ -300,8 +295,8 @@ impl ProblemReport {
impl fmt::Display for ProblemReport {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
writeln!(fmt, "System information:")?;
- for system_info in &self.system_info {
- writeln!(fmt, "{}", system_info)?;
+ for (key, value) in &self.metadata {
+ writeln!(fmt, "{}: {}", key, value)?;
}
writeln!(fmt, "")?;
for &(ref label, ref content) in &self.logs {
@@ -331,6 +326,13 @@ fn read_file_lossy(path: &Path, max_bytes: usize) -> io::Result<String> {
Ok(String::from_utf8_lossy(&buffer).into_owned())
}
+fn collect_metadata() -> HashMap<String, String> {
+ let mut metadata = HashMap::new();
+ metadata.insert(String::from("mullvad-daemon-version"), daemon_version());
+ metadata.insert(String::from("os"), os_version());
+ metadata
+}
+
fn daemon_version() -> String {
format!(
"v{} {}",
diff --git a/mullvad-rpc/src/lib.rs b/mullvad-rpc/src/lib.rs
index bfbf4c6ab6..19d9a29287 100644
--- a/mullvad-rpc/src/lib.rs
+++ b/mullvad-rpc/src/lib.rs
@@ -24,6 +24,8 @@ pub use jsonrpc_client_http::{Error as HttpError, HttpHandle};
use mullvad_types::account::AccountToken;
use mullvad_types::relay_list::RelayList;
+use std::collections::HashMap;
+
static MASTER_API_URI: &str = "https://api.mullvad.net/rpc/";
@@ -37,7 +39,13 @@ jsonrpc_client!(pub struct AccountsProxy {
});
jsonrpc_client!(pub struct ProblemReportProxy {
- pub fn problem_report(&mut self, email: &str, message: &str, log: &str) -> RpcRequest<()>;
+ pub fn problem_report(
+ &mut self,
+ email: &str,
+ message: &str,
+ log: &str,
+ metadata: &HashMap<String, String>)
+ -> RpcRequest<()>;
});
impl ProblemReportProxy<HttpHandle> {