diff --git a/Cargo.lock b/Cargo.lock
index fb200ad..36acd93 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2,12 +2,33 @@
# It is not intended for manual editing.
version = 3
+[[package]]
+name = "android-tzdata"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0"
+
+[[package]]
+name = "android_system_properties"
+version = "0.1.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311"
+dependencies = [
+ "libc",
+]
+
[[package]]
name = "anyhow"
version = "1.0.82"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f538837af36e6f6a9be0faa67f9a314f8119e4e4b5867c6ab40ed60360142519"
+[[package]]
+name = "autocfg"
+version = "1.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0"
+
[[package]]
name = "base64"
version = "0.21.7"
@@ -44,6 +65,20 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
+[[package]]
+name = "chrono"
+version = "0.4.38"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401"
+dependencies = [
+ "android-tzdata",
+ "iana-time-zone",
+ "js-sys",
+ "num-traits",
+ "wasm-bindgen",
+ "windows-targets 0.52.4",
+]
+
[[package]]
name = "core-foundation"
version = "0.9.4"
@@ -202,6 +237,29 @@ version = "0.14.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604"
+[[package]]
+name = "iana-time-zone"
+version = "0.1.60"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141"
+dependencies = [
+ "android_system_properties",
+ "core-foundation-sys",
+ "iana-time-zone-haiku",
+ "js-sys",
+ "wasm-bindgen",
+ "windows-core",
+]
+
+[[package]]
+name = "iana-time-zone-haiku"
+version = "0.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f"
+dependencies = [
+ "cc",
+]
+
[[package]]
name = "ident_case"
version = "1.0.1"
@@ -240,6 +298,25 @@ dependencies = [
"winreg",
]
+[[package]]
+name = "is-docker"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "928bae27f42bc99b60d9ac7334e3a21d10ad8f1835a4e12ec3ec0464765ed1b3"
+dependencies = [
+ "once_cell",
+]
+
+[[package]]
+name = "is-wsl"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "173609498df190136aa7dea1a91db051746d339e18476eed5ca40521f02d7aa5"
+dependencies = [
+ "is-docker",
+ "once_cell",
+]
+
[[package]]
name = "itoa"
version = "1.0.11"
@@ -347,6 +424,15 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9"
+[[package]]
+name = "num-traits"
+version = "0.2.19"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
+dependencies = [
+ "autocfg",
+]
+
[[package]]
name = "nvml-wrapper"
version = "0.8.0"
@@ -376,6 +462,17 @@ version = "1.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"
+[[package]]
+name = "open"
+version = "5.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "61a877bf6abd716642a53ef1b89fb498923a4afca5c754f9050b4d081c05c4b3"
+dependencies = [
+ "is-wsl",
+ "libc",
+ "pathdiff",
+]
+
[[package]]
name = "openssl"
version = "0.10.66"
@@ -420,6 +517,12 @@ dependencies = [
"vcpkg",
]
+[[package]]
+name = "pathdiff"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd"
+
[[package]]
name = "percent-encoding"
version = "2.3.1"
@@ -512,10 +615,12 @@ dependencies = [
name = "reportbook"
version = "0.1.0"
dependencies = [
+ "chrono",
"cpuid",
"installed",
"machine-info",
"native-tls",
+ "open",
"sysinfo 0.30.10",
"ureq",
"whoami",
diff --git a/Cargo.toml b/Cargo.toml
index dfc41f9..8671546 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -11,9 +11,11 @@ whoami = "1.5.1"
machine-info = "1.0.6"
ureq = { version = "2.9.6", default-features = false, features = ["native-tls"] }
native-tls = "0.2.11"
+open = "5.3.0"
+chrono = "0.4.38"
[profile.release]
strip = true
opt-level = "z"
lto = true
-codegen-units = 1
\ No newline at end of file
+codegen-units = 1
diff --git a/README.md b/README.md
index 475aef2..faa0f19 100644
--- a/README.md
+++ b/README.md
@@ -1,11 +1,11 @@
ReportBook
-
Simplistic automated diagnostic tool
-
+
Simplistic automated diagnostic tool for Windows and macOS
+
![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/Loudbooks/ReportBook/rust.yml?style=for-the-badge)
-ReportBook is a process used to diagnose a variety of possible issues on your device. Output is uploaded to [PasteBook](https://pastebook.dev), to be deleted entirely after 24 hours. You can find an example [here](https://pastebook.dev/pastes/millie-shadow-bard-milkchocolate?inspect).
+ReportBook is a process used to diagnose a variety of possible issues on your device. Output is shown in a plain text file. You can find an example [here](https://pastebook.dev/pastes/millie-shadow-bard-milkchocolate?inspect).
This program was designed with the intention of being used by software support teams, but is available to anyone who wishes to use it. Source code can be viewed on [GitHub](https://github.com/Loudbooks/ReportBook) should you be interested in how it works.
diff --git a/src/datagatherers/processes.rs b/src/datagatherers/processes.rs
index 863c640..24b89bd 100644
--- a/src/datagatherers/processes.rs
+++ b/src/datagatherers/processes.rs
@@ -5,7 +5,7 @@ pub fn gather_processes(sys: &System) -> Vec {
let username = whoami::username();
let mut processes: Vec = Vec::new();
- for (pid, process) in sys.processes() {
+ for (_pid, process) in sys.processes() {
match process.cwd() {
None => {}
Some(_) => {
@@ -37,7 +37,6 @@ pub fn gather_processes(sys: &System) -> Vec {
};
let process = Process {
- pid: *pid,
name: process.name().to_string(),
path,
memory: process.memory() as f64,
diff --git a/src/file_handler.rs b/src/file_handler.rs
new file mode 100644
index 0000000..29b7be2
--- /dev/null
+++ b/src/file_handler.rs
@@ -0,0 +1,39 @@
+use std::fs;
+
+pub struct FileHandler {
+ pub lines: Vec,
+}
+
+impl FileHandler {
+ pub fn new() -> Self {
+ Self {
+ lines: Vec::new(),
+ }
+ }
+
+ pub fn add_line(&mut self, line: String) {
+ self.lines.push(line);
+ }
+
+ pub fn submit(&self) {
+ if cfg!(target_os = "windows") {
+ self.submit_windows();
+ } else {
+ self.submit_unix();
+ }
+ }
+
+ fn submit_windows(&self) {
+ let path = "C:\\Temp\\ReportBook.txt";
+ fs::write(path, self.lines.join("\n").as_bytes()).expect("Failed to create tempfile");
+
+ open::that(path).expect("Failed to open file");
+ }
+
+ fn submit_unix(&self) {
+ let path = "/tmp/ReportBook.txt";
+ fs::write(path, self.lines.join("\n").as_bytes()).expect("Failed to create tempfile");
+
+ open::that(path).expect("Failed to open file");
+ }
+}
\ No newline at end of file
diff --git a/src/httphandler.rs b/src/httphandler.rs
deleted file mode 100644
index c74f8cf..0000000
--- a/src/httphandler.rs
+++ /dev/null
@@ -1,44 +0,0 @@
-use std::io::Cursor;
-use std::sync::Arc;
-
-use native_tls::TlsConnector;
-use ureq::AgentBuilder;
-
-pub struct HttpHandler {
- pub url: String,
- pub lines: Vec,
-}
-
-impl HttpHandler {
- pub fn new(url: String) -> Self {
- Self {
- url,
- lines: Vec::new(),
- }
- }
-
- pub fn add_line(&mut self, line: String) {
- self.lines.push(line);
- }
-
- pub fn submit(&self, name: &str) {
- println!("Uploading your paste...");
- let title = format!("{}'s ReportBook", name);
-
- let agent = AgentBuilder::new()
- .tls_connector(Arc::new(TlsConnector::new().unwrap()))
- .build();
- let result = agent
- .post(&self.url)
- .set("content-type", "text/plain")
- .set("title", title.as_str())
- .set("reportbook", "true")
- .send(Cursor::new(self.lines.join("\n")))
- .unwrap()
- .into_string()
- .unwrap();
-
- println!("View your report at: {}", result);
- println!("Share this link with whoever asked you to run this report!")
- }
-}
\ No newline at end of file
diff --git a/src/main.rs b/src/main.rs
index c1e1a6e..012546b 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,11 +1,13 @@
-use crate::process::prettify_memory;
+use std::io::stdin;
+
use machine_info::Machine;
-use std::io::{stdin, stdout, Write};
use sysinfo::System;
+use crate::process::prettify_memory;
+
mod app;
mod datagatherers;
-mod httphandler;
+mod file_handler;
mod process;
fn main() {
@@ -16,14 +18,14 @@ The intention of this process is to gather information on hardware and software
Rest assured, identifiable information including your name and your address will be omitted from the resulting report.
-Reports will be uploaded to a pastebin, to expire after nine hours.
+Reports will be opened in your default text editor once completed.
"#;
println!("{}", intro);
wait_for_enter("continue");
let mut http_handler =
- httphandler::HttpHandler::new("https://pastebook.dev/upload".to_string());
+ file_handler::FileHandler::new();
let mut sys = System::new_all();
sys.refresh_all();
@@ -39,6 +41,7 @@ Reports will be uploaded to a pastebin, to expire after nine hours.
let gpus = machine.system_info().graphics;
let username = whoami::username();
let is_alphanumeric_username = username.chars().all(char::is_alphanumeric);
+ let log_creation = chrono::Utc::now().format("%Y-%m-%d %H:%M").to_string();
let os_name = format!(
"{}, {}",
@@ -160,7 +163,14 @@ Reports will be uploaded to a pastebin, to expire after nine hours.
let spaces = INFORMATION_SPACES - id.len();
format!("{}{}{}", id, " ".repeat(spaces), value)
};
+
+ let log_creation_str = {
+ let id = "Log Creation: ";
+ let spaces = INFORMATION_SPACES - id.len();
+ format!("{}{}{}", id, " ".repeat(spaces), log_creation)
+ };
+
http_handler.add_line(os_name_str.to_string());
http_handler.add_line(total_memory_str);
if total_swap > 0 {
@@ -176,6 +186,8 @@ Reports will be uploaded to a pastebin, to expire after nine hours.
http_handler.add_line(gpu);
}
http_handler.add_line(alphanumeric_username);
+ http_handler.add_line(log_creation_str);
+
http_handler.add_line("".to_string());
let processes = datagatherers::processes::gather_processes(&sys);
@@ -231,27 +243,11 @@ Reports will be uploaded to a pastebin, to expire after nine hours.
}
}
- print!("Enter your username: ");
- let username = user_input();
-
- http_handler.submit(username.as_str());
+ http_handler.submit();
wait_for_enter("exit")
}
-fn user_input() -> String {
- let mut input = String::new();
-
- stdout().flush().expect("Failed to flush");
- stdin()
- .read_line(&mut input)
- .expect("Did not enter a correct string");
-
- input = input.trim().to_string();
-
- input
-}
-
fn wait_for_enter(message: &str) {
println!("Press enter to {}.", message);
let _ = stdin().read_line(&mut String::new());
diff --git a/src/process.rs b/src/process.rs
index c7aa511..99c01c6 100644
--- a/src/process.rs
+++ b/src/process.rs
@@ -1,7 +1,4 @@
-use sysinfo::Pid;
-
pub struct Process {
- pub pid: Pid,
pub name: String,
pub path: String,
pub memory: f64,