All checks were successful
ci / test (pull_request) Successful in 4m54s
stdin read_line echoed the passphrase. rpassword disables tty echo. ONIONWIRE_STORE_PASSPHRASE still skips the prompt.
50 lines
1.6 KiB
Rust
50 lines
1.6 KiB
Rust
use onionwire::tui::AppExit;
|
|
|
|
fn print_help() {
|
|
let v = env!("CARGO_PKG_VERSION");
|
|
println!("onionwire {v} — Tor messenger (in-process Arti). Runs a TUI; no server.");
|
|
println!("Usage: onionwire [--version | --help]");
|
|
println!("Data: $ONIONWIRE_HOME or ~/.local/share/onionwire");
|
|
}
|
|
|
|
#[tokio::main]
|
|
async fn main() {
|
|
match std::env::args().nth(1).as_deref() {
|
|
Some("--version") | Some("-V") => {
|
|
println!("onionwire {}", env!("CARGO_PKG_VERSION"));
|
|
return;
|
|
}
|
|
Some("--help") | Some("-h") => {
|
|
print_help();
|
|
return;
|
|
}
|
|
Some(other) => {
|
|
eprintln!("onionwire: unknown argument {other}");
|
|
eprintln!("Try: onionwire --help");
|
|
std::process::exit(2);
|
|
}
|
|
None => {}
|
|
}
|
|
|
|
if let Err(e) = boot().await {
|
|
eprintln!("onionwire: {e}");
|
|
std::process::exit(1);
|
|
}
|
|
}
|
|
|
|
async fn boot() -> Result<(), String> {
|
|
let home = onionwire::Store::home_dir().map_err(|e| e.to_string())?;
|
|
let pass = onionwire::resolve_store_passphrase(|p| rpassword::prompt_password(p))
|
|
.map_err(|e| e.to_string())?;
|
|
eprintln!("onionwire: bootstrapping Arti…");
|
|
let node = onionwire::node::Node::start_with_passphrase(home.clone(), &pass).await?;
|
|
let handle = tokio::runtime::Handle::current();
|
|
let exit = tokio::task::spawn_blocking(move || onionwire::tui::run(node, handle))
|
|
.await
|
|
.map_err(|e| e.to_string())??;
|
|
if exit == AppExit::WipeAll {
|
|
onionwire::Store::wipe_all(&home).map_err(|e| e.to_string())?;
|
|
eprintln!("onionwire: all local data wiped");
|
|
}
|
|
Ok(())
|
|
}
|