summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorLinus Färnstrand <linus@mullvad.net>2017-10-30 17:15:19 +0100
committerLinus Färnstrand <linus@mullvad.net>2017-10-30 17:15:19 +0100
commit059e48363a20fe4680d9e7b46a9de463d2db11e2 (patch)
treec5f8a8872de7354e66501f0de509ce288df438ee
parent3df28edf3258b3de877a14becac237e413978e02 (diff)
downloadmullvadvpn-059e48363a20fe4680d9e7b46a9de463d2db11e2.tar.xz
mullvadvpn-059e48363a20fe4680d9e7b46a9de463d2db11e2.zip
Add daemon, os and kernel info to problem report
-rw-r--r--Cargo.lock17
-rw-r--r--mullvad-daemon/Cargo.toml1
-rw-r--r--mullvad-daemon/src/bin/problem-report.rs80
3 files changed, 93 insertions, 5 deletions
diff --git a/Cargo.lock b/Cargo.lock
index d0c58be2c7..a6c2fe18f8 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -354,6 +354,11 @@ dependencies = [
]
[[package]]
+name = "gcc"
+version = "0.3.54"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
name = "glob"
version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -684,6 +689,7 @@ dependencies = [
"serde 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)",
"simple-signal 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "sys-info 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"talpid-core 0.1.0",
"talpid-ipc 0.1.0",
"talpid-types 0.1.0",
@@ -1220,6 +1226,15 @@ dependencies = [
]
[[package]]
+name = "sys-info"
+version = "0.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
name = "take"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1584,6 +1599,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum fuchsia-zircon-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "43f3795b4bae048dc6123a6b972cadde2e676f9ded08aef6bb77f5f157684a82"
"checksum futures 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "05a23db7bd162d4e8265968602930c476f688f0c180b44bdaf55e0cb2c687558"
"checksum futures-cpupool 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "e86f49cc0d92fe1b97a5980ec32d56208272cbb00f15044ea9e2799dde766fdf"
+"checksum gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)" = "5e33ec290da0d127825013597dbdfc28bee4964690c7ce1166cbc2a7bd08b1bb"
"checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb"
"checksum globset 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "90d069fe6beb9be359ef505650b3f73228c5591a3c4b1f32be2f4f44459ffa3a"
"checksum httparse 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "af2f2dd97457e8fb1ae7c5a420db346af389926e36f43768b96f101546b04a07"
@@ -1675,6 +1691,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum syntex_errors 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)" = "867cc5c2d7140ae7eaad2ae9e8bf39cb18a67ca651b7834f88d46ca98faadb9c"
"checksum syntex_pos 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)" = "13ad4762fe52abc9f4008e85c4fb1b1fe3aa91ccb99ff4826a439c7c598e1047"
"checksum syntex_syntax 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6e0e4dbae163dd98989464c23dd503161b338790640e11537686f2ef0f25c791"
+"checksum sys-info 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6e0c80518e54ce6bd40e8262b386395f2154dcfaf22ff8102380dc5c7bed3683"
"checksum take 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b157868d8ac1f56b64604539990685fa7611d8fa9e5476cf0c02cf34d32917c5"
"checksum tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "87974a6f5c1dfb344d733055601650059a3363de2a6104819293baff662132d6"
"checksum term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "fa63644f74ce96fbeb9b794f66aff2a52d601cbd5e80f4b97123e3899f4570f1"
diff --git a/mullvad-daemon/Cargo.toml b/mullvad-daemon/Cargo.toml
index 7449b9120e..dcbcb576df 100644
--- a/mullvad-daemon/Cargo.toml
+++ b/mullvad-daemon/Cargo.toml
@@ -31,6 +31,7 @@ jsonrpc-ws-server = { git = "https://github.com/paritytech/jsonrpc", tag = "v7.1
uuid = { version = "0.5", features = ["v4"] }
lazy_static = "0.2"
toml = "0.4"
+sys-info = "0.5"
mullvad-types = { path = "../mullvad-types" }
mullvad-rpc = { path = "../mullvad-rpc" }
diff --git a/mullvad-daemon/src/bin/problem-report.rs b/mullvad-daemon/src/bin/problem-report.rs
index 8ecae0a0e5..447de8796f 100644
--- a/mullvad-daemon/src/bin/problem-report.rs
+++ b/mullvad-daemon/src/bin/problem-report.rs
@@ -10,6 +10,7 @@
extern crate clap;
#[macro_use]
extern crate error_chain;
+extern crate sys_info;
extern crate mullvad_rpc;
@@ -19,6 +20,7 @@ use std::fmt;
use std::fs::File;
use std::io::{self, Read, Seek, SeekFrom, Write};
use std::path::{Path, PathBuf};
+use std::process::Command;
/// Maximum number of bytes to read from each log file
const LOG_MAX_READ_BYTES: usize = 5 * 1024 * 1024;
@@ -48,10 +50,10 @@ error_chain!{
quick_main!(run);
fn run() -> Result<()> {
- let app = clap::App::new(crate_name!())
+ let app = clap::App::new("problem-report")
.version(crate_version!())
.author(crate_authors!())
- .about(crate_description!())
+ .about("Mullvad VPN problem report tool. Collects logs and send them to Mullvad support.")
.setting(clap::AppSettings::SubcommandRequired)
.subcommand(
clap::SubCommand::with_name("collect")
@@ -121,7 +123,7 @@ fn run() -> Result<()> {
}
fn collect_report(log_paths: &[&Path], output_path: &Path) -> Result<()> {
- let mut problem_report = ProblemReport::default();
+ let mut problem_report = ProblemReport::new();
for log_path in log_paths {
problem_report.add_log(log_path);
}
@@ -149,15 +151,32 @@ fn write_problem_report(path: &Path, problem_report: ProblemReport) -> io::Resul
Ok(())
}
-#[derive(Debug, Default)]
+
+#[derive(Debug)]
struct ProblemReport {
+ system_info: Vec<String>,
logs: Vec<(String, String)>,
}
impl ProblemReport {
+ pub fn new() -> Self {
+ ProblemReport {
+ system_info: Self::collect_system_info(),
+ logs: Vec::new(),
+ }
+ }
+
+ fn collect_system_info() -> Vec<String> {
+ vec![
+ format!("Mullvad daemon: {}", daemon_version()),
+ format!("OS: {}", os_version()),
+ format!("Kernel: {}", kernel_version()),
+ ]
+ }
+
/// Attach file log to this report. This method uses the error chain instead of log
/// contents if error occurred when reading log file.
- fn add_log(&mut self, path: &Path) {
+ pub fn add_log(&mut self, path: &Path) {
let content = read_file_lossy(path, LOG_MAX_READ_BYTES)
.chain_err(|| ErrorKind::ReadLogError(path.to_path_buf()))
.unwrap_or_else(|e| e.display_chain().to_string());
@@ -168,6 +187,11 @@ 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)?;
+ }
+ writeln!(fmt, "")?;
for &(ref label, ref content) in &self.logs {
writeln!(fmt, "{}", LOG_DELIMITER)?;
writeln!(fmt, "Log: {}", label)?;
@@ -194,3 +218,49 @@ fn read_file_lossy(path: &Path, max_bytes: usize) -> io::Result<String> {
file.take(max_bytes as u64).read_to_end(&mut buffer)?;
Ok(String::from_utf8_lossy(&buffer).into_owned())
}
+
+fn daemon_version() -> String {
+ format!(
+ "v{} {}",
+ env!("CARGO_PKG_VERSION"),
+ include_str!(concat!(env!("OUT_DIR"), "/git-commit-info.txt"))
+ )
+}
+
+fn kernel_version() -> String {
+ sys_info::os_release().unwrap_or(String::from("Unknown"))
+}
+
+#[cfg(target_os = "linux")]
+fn os_version() -> String {
+ format!(
+ "Linux, {}",
+ command_stdout_lossy("lsb_release", &["-ds"])
+ .unwrap_or(String::from("[Failed to get LSB release]"))
+ )
+}
+
+#[cfg(target_os = "macos")]
+fn os_version() -> String {
+ format!(
+ "macOS {}",
+ command_stdout_lossy("sw_vers", &["-productVersion"])
+ .unwrap_or(String::from("[Failed to detect version]"))
+ )
+}
+
+#[cfg(windows)]
+fn os_version() -> String {
+ String::from("Windows")
+}
+
+/// Helper for getting stdout of some command as a String. Ignores the exit code of the command.
+fn command_stdout_lossy(cmd: &str, args: &[&str]) -> Option<String> {
+ Command::new(cmd)
+ .args(args)
+ .output()
+ .map(|output| {
+ String::from_utf8_lossy(&output.stdout).trim().to_string()
+ })
+ .ok()
+}