➕ add diceware subcommand
parent
820c5aeef4
commit
097c9cf313
|
@ -1243,6 +1243,7 @@ dependencies = [
|
||||||
"ptth_file_server",
|
"ptth_file_server",
|
||||||
"ptth_server",
|
"ptth_server",
|
||||||
"quic_demo",
|
"quic_demo",
|
||||||
|
"rand",
|
||||||
"reqwest",
|
"reqwest",
|
||||||
"rusty_ulid",
|
"rusty_ulid",
|
||||||
"sha2",
|
"sha2",
|
||||||
|
|
|
@ -19,6 +19,7 @@ hex = "0.4.3"
|
||||||
ptth_file_server = { path = "../ptth_file_server_bin" }
|
ptth_file_server = { path = "../ptth_file_server_bin" }
|
||||||
ptth_server = { path = "../ptth_server" }
|
ptth_server = { path = "../ptth_server" }
|
||||||
quic_demo = { path = "../../prototypes/quic_demo" }
|
quic_demo = { path = "../../prototypes/quic_demo" }
|
||||||
|
rand = "0.8.4"
|
||||||
rusty_ulid = "0.10.1"
|
rusty_ulid = "0.10.1"
|
||||||
sha2 = "0.9.8"
|
sha2 = "0.9.8"
|
||||||
tokio = { version = "1.8.1", features = ["full"] }
|
tokio = { version = "1.8.1", features = ["full"] }
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
use rand::Rng;
|
||||||
|
|
||||||
|
pub fn main () {
|
||||||
|
let wordlist = include_str! ("eff_short_wordlist_1.txt");
|
||||||
|
let words: Vec <_> = wordlist.split ('\n').take (1253).collect ();
|
||||||
|
|
||||||
|
assert_eq! (words.len (), 1253);
|
||||||
|
assert_eq! (words [0], "acid");
|
||||||
|
assert_eq! (words [600], "large");
|
||||||
|
assert_eq! (words [1252], "zoom");
|
||||||
|
|
||||||
|
let mut rng = rand::thread_rng ();
|
||||||
|
|
||||||
|
let random_words: Vec <&str> = (0..8)
|
||||||
|
.map (|_| {
|
||||||
|
words [rng.gen_range (0..words.len ())]
|
||||||
|
})
|
||||||
|
.collect ();
|
||||||
|
|
||||||
|
let passphrase = random_words.join (" ");
|
||||||
|
|
||||||
|
println! ("{}", passphrase);
|
||||||
|
}
|
|
@ -5,11 +5,13 @@ use std::{
|
||||||
|
|
||||||
use tokio::sync::watch;
|
use tokio::sync::watch;
|
||||||
|
|
||||||
|
mod diceware;
|
||||||
mod download;
|
mod download;
|
||||||
mod ulid;
|
mod ulid;
|
||||||
|
|
||||||
#[derive (Clone, Copy, Debug, PartialEq)]
|
#[derive (Clone, Copy, Debug, PartialEq)]
|
||||||
enum Subcommand {
|
enum Subcommand {
|
||||||
|
Diceware,
|
||||||
Download,
|
Download,
|
||||||
PtthServer,
|
PtthServer,
|
||||||
PtthFileServer,
|
PtthFileServer,
|
||||||
|
@ -27,6 +29,7 @@ async fn main () -> anyhow::Result <()> {
|
||||||
|
|
||||||
let (subcommand, args) = parse_args (&args)?;
|
let (subcommand, args) = parse_args (&args)?;
|
||||||
match subcommand {
|
match subcommand {
|
||||||
|
Diceware => Ok (diceware::main ()),
|
||||||
Download => download::main (&args).await,
|
Download => download::main (&args).await,
|
||||||
PtthServer => ptth_server::executable::main (&args).await,
|
PtthServer => ptth_server::executable::main (&args).await,
|
||||||
PtthFileServer => ptth_file_server::main (&args).await,
|
PtthFileServer => ptth_file_server::main (&args).await,
|
||||||
|
@ -50,6 +53,7 @@ fn parse_subcommand (arg: &str) -> Option <Subcommand>
|
||||||
use Subcommand::*;
|
use Subcommand::*;
|
||||||
|
|
||||||
let map = vec! [
|
let map = vec! [
|
||||||
|
("diceware", Diceware),
|
||||||
("download", Download),
|
("download", Download),
|
||||||
("ptth_server", PtthServer),
|
("ptth_server", PtthServer),
|
||||||
("ptth_file_server", PtthFileServer),
|
("ptth_file_server", PtthFileServer),
|
||||||
|
|
Loading…
Reference in New Issue