From 5fbba7112bd738e18c1f671598ae4c128fd28e1e Mon Sep 17 00:00:00 2001 From: kruserr <46799551+kruserr@users.noreply.github.com> Date: Tue, 12 Mar 2024 19:26:19 +0000 Subject: [PATCH 1/7] feat: #1: init timer cli --- Cargo.lock | 139 ++++++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 1 + src/lib.rs | 2 + src/main.rs | 99 ++++++++++++++++++++++++++++++- src/timer/create.rs | 11 ++++ src/timer/list.rs | 9 +++ src/timer/mod.rs | 4 ++ src/timer/print.rs | 19 ++++++ src/timer/stop.rs | 20 +++++++ 9 files changed, 303 insertions(+), 1 deletion(-) create mode 100644 src/timer/create.rs create mode 100644 src/timer/list.rs create mode 100644 src/timer/mod.rs create mode 100644 src/timer/print.rs create mode 100644 src/timer/stop.rs diff --git a/Cargo.lock b/Cargo.lock index f36aeea..3764a57 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,145 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi", + "libc", + "winapi", +] + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "clap" +version = "3.2.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123" +dependencies = [ + "atty", + "bitflags", + "clap_lex", + "indexmap", + "strsim", + "termcolor", + "textwrap", +] + +[[package]] +name = "clap_lex" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5" +dependencies = [ + "os_str_bytes", +] + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + +[[package]] +name = "hermit-abi" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +dependencies = [ + "libc", +] + [[package]] name = "i6" version = "0.1.5" +dependencies = [ + "clap", +] + +[[package]] +name = "indexmap" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +dependencies = [ + "autocfg", + "hashbrown", +] + +[[package]] +name = "libc" +version = "0.2.153" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" + +[[package]] +name = "os_str_bytes" +version = "6.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2355d85b9a3786f481747ced0e0ff2ba35213a1f9bd406ed906554d7af805a1" + +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + +[[package]] +name = "termcolor" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "textwrap" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23d434d3f8967a09480fb04132ebe0a3e088c173e6d0ee7897abbdf4eab0f8b9" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" +dependencies = [ + "winapi", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/Cargo.toml b/Cargo.toml index b0bcf48..3bdc31f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,3 +11,4 @@ keywords = ["cli", "terminal", "utility", "tool", "command"] categories = ["command-line-interface", "command-line-utilities", "development-tools"] [dependencies] +clap = "3" diff --git a/src/lib.rs b/src/lib.rs index 01c3ae9..783fd9e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -52,3 +52,5 @@ //! cargo install --locked --path . //! i6 //! ``` + +pub mod timer; diff --git a/src/main.rs b/src/main.rs index 80a1832..4d9c0a9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,100 @@ +use clap::{App, Arg, SubCommand}; + fn main() { - println!("Hello, world!"); +let matches = App::new("i6") + .subcommand( + SubCommand::with_name("timer") + .about("Manages timers") + .arg( + Arg::with_name("minutes") + .index(1) + .takes_value(true), + ) + .arg( + Arg::with_name("name") + .index(2) + .takes_value(true), + ) + .subcommand( + SubCommand::with_name("create") + .about("Creates a new timer") + .arg( + Arg::with_name("minutes") + .short('m') + .long("minutes") + .takes_value(true) + .help("Sets the duration of the timer in minutes"), + ) + .arg( + Arg::with_name("name") + .short('n') + .long("name") + .takes_value(true) + .help("Sets the name of the timer"), + ), + ) + .subcommand( + SubCommand::with_name("list") + .about("Lists all timers") + .alias("ls"), + ) + .subcommand( + SubCommand::with_name("stop") + .about("Stops a timer") + .arg( + Arg::with_name("name") + .short('n') + .long("name") + .takes_value(true) + .help("Stops the timer with the given name"), + ) + .arg( + Arg::with_name("all") + .short('a') + .long("all") + .takes_value(false) + .help("Stops all timers"), + ), + ) + .subcommand( + SubCommand::with_name("history") + .about("Shows the history of all timers") + .alias("log") + .arg( + Arg::with_name("json") + .short('j') + .long("json") + .takes_value(false) + .help("Prints the history in JSON format"), + ), + ), + ) + .get_matches(); + + + if let Some(matches) = matches.subcommand_matches("timer") { + if let Some(matches) = matches.subcommand_matches("create") { + let minutes = matches.value_of("minutes").unwrap_or_default(); + let name = matches.value_of("name").unwrap_or_default(); + i6::timer::create::create_timer(minutes, name); + } else if matches.subcommand_matches("list").is_some() { + i6::timer::list::list_timers(); + } else if let Some(matches) = matches.subcommand_matches("stop") { + if matches.is_present("all") { + i6::timer::stop::stop_all_timers(); + } else { + i6::timer::stop::stop_timer(matches.value_of("name").unwrap_or_default()); + } + } else if let Some(matches) = matches.subcommand_matches("history") { + if matches.is_present("json") { + i6::timer::print::print_history_json(); + } else { + i6::timer::print::print_history(); + } + } else if let (Some(minutes), Some(name)) = (matches.value_of("minutes"), matches.value_of("name")) { + i6::timer::create::create_timer(minutes, name); + } else if let Some(minutes) = matches.value_of("minutes") { + i6::timer::create::create_timer(minutes, ""); + } + } } diff --git a/src/timer/create.rs b/src/timer/create.rs new file mode 100644 index 0000000..69dfa2e --- /dev/null +++ b/src/timer/create.rs @@ -0,0 +1,11 @@ +pub fn create_timer(minutes: &str, name: &str) { + // Implement the create timer functionality here + println!("Creating a timer named '{}' for {} minutes...", name, minutes); +} +#[test] +fn test_create_timer() { + let minutes = "10"; + let name = "test"; + create_timer(minutes, name); + // Add assertions here based on your implementation +} diff --git a/src/timer/list.rs b/src/timer/list.rs new file mode 100644 index 0000000..d997049 --- /dev/null +++ b/src/timer/list.rs @@ -0,0 +1,9 @@ +pub fn list_timers() { + // Implement the list timers functionality here + println!("Listing all timers..."); +} +#[test] +fn test_list_timers() { + list_timers(); + // Add assertions here based on your implementation +} diff --git a/src/timer/mod.rs b/src/timer/mod.rs new file mode 100644 index 0000000..6c1d7f9 --- /dev/null +++ b/src/timer/mod.rs @@ -0,0 +1,4 @@ +pub mod create; +pub mod list; +pub mod stop; +pub mod print; diff --git a/src/timer/print.rs b/src/timer/print.rs new file mode 100644 index 0000000..7023105 --- /dev/null +++ b/src/timer/print.rs @@ -0,0 +1,19 @@ +pub fn print_history() { + // Implement the history functionality here + println!("Printing the history of all timers..."); +} +#[test] +fn test_print_history() { + print_history(); + // Add assertions here based on your implementation +} + +pub fn print_history_json() { + // Implement the history in JSON format functionality here + println!("Printing the history of all timers in JSON format..."); +} +#[test] +fn test_print_history_json() { + print_history_json(); + // Add assertions here based on your implementation +} diff --git a/src/timer/stop.rs b/src/timer/stop.rs new file mode 100644 index 0000000..e1c6391 --- /dev/null +++ b/src/timer/stop.rs @@ -0,0 +1,20 @@ +pub fn stop_timer(name: &str) { + // Implement the stop timer functionality here + println!("Stopping the timer named '{}'...", name); +} +#[test] +fn test_stop_timer() { + let name = "test"; + stop_timer(name); + // Add assertions here based on your implementation +} + +pub fn stop_all_timers() { + // Implement the stop all timers functionality here + println!("Stopping all timers..."); +} +#[test] +fn test_stop_all_timers() { + stop_all_timers(); + // Add assertions here based on your implementation +} From 8cb46a2edbb7cb5fb918e6445dafc5557b568a3a Mon Sep 17 00:00:00 2001 From: kruserr <46799551+kruserr@users.noreply.github.com> Date: Sun, 17 Mar 2024 08:36:09 +0000 Subject: [PATCH 2/7] style: fmt --- src/timer/create.rs | 12 ++++++------ src/timer/list.rs | 8 ++++---- src/timer/mod.rs | 2 +- src/timer/print.rs | 16 ++++++++-------- src/timer/stop.rs | 18 +++++++++--------- 5 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/timer/create.rs b/src/timer/create.rs index 69dfa2e..cefa712 100644 --- a/src/timer/create.rs +++ b/src/timer/create.rs @@ -1,11 +1,11 @@ pub fn create_timer(minutes: &str, name: &str) { - // Implement the create timer functionality here - println!("Creating a timer named '{}' for {} minutes...", name, minutes); + // Implement the create timer functionality here + println!("Creating a timer named '{}' for {} minutes...", name, minutes); } #[test] fn test_create_timer() { - let minutes = "10"; - let name = "test"; - create_timer(minutes, name); - // Add assertions here based on your implementation + let minutes = "10"; + let name = "test"; + create_timer(minutes, name); + // Add assertions here based on your implementation } diff --git a/src/timer/list.rs b/src/timer/list.rs index d997049..2145dbc 100644 --- a/src/timer/list.rs +++ b/src/timer/list.rs @@ -1,9 +1,9 @@ pub fn list_timers() { - // Implement the list timers functionality here - println!("Listing all timers..."); + // Implement the list timers functionality here + println!("Listing all timers..."); } #[test] fn test_list_timers() { - list_timers(); - // Add assertions here based on your implementation + list_timers(); + // Add assertions here based on your implementation } diff --git a/src/timer/mod.rs b/src/timer/mod.rs index 6c1d7f9..0536554 100644 --- a/src/timer/mod.rs +++ b/src/timer/mod.rs @@ -1,4 +1,4 @@ pub mod create; pub mod list; -pub mod stop; pub mod print; +pub mod stop; diff --git a/src/timer/print.rs b/src/timer/print.rs index 7023105..5a9d129 100644 --- a/src/timer/print.rs +++ b/src/timer/print.rs @@ -1,19 +1,19 @@ pub fn print_history() { - // Implement the history functionality here - println!("Printing the history of all timers..."); + // Implement the history functionality here + println!("Printing the history of all timers..."); } #[test] fn test_print_history() { - print_history(); - // Add assertions here based on your implementation + print_history(); + // Add assertions here based on your implementation } pub fn print_history_json() { - // Implement the history in JSON format functionality here - println!("Printing the history of all timers in JSON format..."); + // Implement the history in JSON format functionality here + println!("Printing the history of all timers in JSON format..."); } #[test] fn test_print_history_json() { - print_history_json(); - // Add assertions here based on your implementation + print_history_json(); + // Add assertions here based on your implementation } diff --git a/src/timer/stop.rs b/src/timer/stop.rs index e1c6391..9d6ec1e 100644 --- a/src/timer/stop.rs +++ b/src/timer/stop.rs @@ -1,20 +1,20 @@ pub fn stop_timer(name: &str) { - // Implement the stop timer functionality here - println!("Stopping the timer named '{}'...", name); + // Implement the stop timer functionality here + println!("Stopping the timer named '{}'...", name); } #[test] fn test_stop_timer() { - let name = "test"; - stop_timer(name); - // Add assertions here based on your implementation + let name = "test"; + stop_timer(name); + // Add assertions here based on your implementation } pub fn stop_all_timers() { - // Implement the stop all timers functionality here - println!("Stopping all timers..."); + // Implement the stop all timers functionality here + println!("Stopping all timers..."); } #[test] fn test_stop_all_timers() { - stop_all_timers(); - // Add assertions here based on your implementation + stop_all_timers(); + // Add assertions here based on your implementation } From d5c9a26aaa785921fb18d872802f35cb5307c75a Mon Sep 17 00:00:00 2001 From: kruserr <46799551+kruserr@users.noreply.github.com> Date: Sun, 17 Mar 2024 08:36:26 +0000 Subject: [PATCH 3/7] style: fmt --- src/main.rs | 192 +++++++++++++++++++++++++++------------------------- 1 file changed, 101 insertions(+), 91 deletions(-) diff --git a/src/main.rs b/src/main.rs index 4d9c0a9..fec203d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,100 +1,110 @@ use clap::{App, Arg, SubCommand}; fn main() { -let matches = App::new("i6") + let http_id = "http"; + let https_id = "https"; + + let matches = App::new("i6") + .subcommand( + SubCommand::with_name(http_id).about("Start a static http server"), + ) + .subcommand( + SubCommand::with_name(https_id).about("Start a static https server"), + ) + .subcommand( + SubCommand::with_name("timer") + .about("Manages timers") + .arg(Arg::with_name("minutes").index(1).takes_value(true)) + .arg(Arg::with_name("name").index(2).takes_value(true)) + .subcommand( + SubCommand::with_name("create") + .about("Creates a new timer") + .arg( + Arg::with_name("minutes") + .short('m') + .long("minutes") + .takes_value(true) + .help("Sets the duration of the timer in minutes"), + ) + .arg( + Arg::with_name("name") + .short('n') + .long("name") + .takes_value(true) + .help("Sets the name of the timer"), + ), + ) .subcommand( - SubCommand::with_name("timer") - .about("Manages timers") - .arg( - Arg::with_name("minutes") - .index(1) - .takes_value(true), - ) - .arg( - Arg::with_name("name") - .index(2) - .takes_value(true), - ) - .subcommand( - SubCommand::with_name("create") - .about("Creates a new timer") - .arg( - Arg::with_name("minutes") - .short('m') - .long("minutes") - .takes_value(true) - .help("Sets the duration of the timer in minutes"), - ) - .arg( - Arg::with_name("name") - .short('n') - .long("name") - .takes_value(true) - .help("Sets the name of the timer"), - ), - ) - .subcommand( - SubCommand::with_name("list") - .about("Lists all timers") - .alias("ls"), - ) - .subcommand( - SubCommand::with_name("stop") - .about("Stops a timer") - .arg( - Arg::with_name("name") - .short('n') - .long("name") - .takes_value(true) - .help("Stops the timer with the given name"), - ) - .arg( - Arg::with_name("all") - .short('a') - .long("all") - .takes_value(false) - .help("Stops all timers"), - ), - ) - .subcommand( - SubCommand::with_name("history") - .about("Shows the history of all timers") - .alias("log") - .arg( - Arg::with_name("json") - .short('j') - .long("json") - .takes_value(false) - .help("Prints the history in JSON format"), - ), - ), + SubCommand::with_name("list").about("Lists all timers").alias("ls"), ) - .get_matches(); + .subcommand( + SubCommand::with_name("stop") + .about("Stops a timer") + .arg( + Arg::with_name("name") + .short('n') + .long("name") + .takes_value(true) + .help("Stops the timer with the given name"), + ) + .arg( + Arg::with_name("all") + .short('a') + .long("all") + .takes_value(false) + .help("Stops all timers"), + ), + ) + .subcommand( + SubCommand::with_name("history") + .about("Shows the history of all timers") + .alias("log") + .arg( + Arg::with_name("json") + .short('j') + .long("json") + .takes_value(false) + .help("Prints the history in JSON format"), + ), + ), + ) + .get_matches(); + + if let Some(matches) = matches.subcommand_matches(http_id) { + println!("http"); + } + if let Some(matches) = matches.subcommand_matches(https_id) { + println!("https"); + } - if let Some(matches) = matches.subcommand_matches("timer") { - if let Some(matches) = matches.subcommand_matches("create") { - let minutes = matches.value_of("minutes").unwrap_or_default(); - let name = matches.value_of("name").unwrap_or_default(); - i6::timer::create::create_timer(minutes, name); - } else if matches.subcommand_matches("list").is_some() { - i6::timer::list::list_timers(); - } else if let Some(matches) = matches.subcommand_matches("stop") { - if matches.is_present("all") { - i6::timer::stop::stop_all_timers(); - } else { - i6::timer::stop::stop_timer(matches.value_of("name").unwrap_or_default()); - } - } else if let Some(matches) = matches.subcommand_matches("history") { - if matches.is_present("json") { - i6::timer::print::print_history_json(); - } else { - i6::timer::print::print_history(); - } - } else if let (Some(minutes), Some(name)) = (matches.value_of("minutes"), matches.value_of("name")) { - i6::timer::create::create_timer(minutes, name); - } else if let Some(minutes) = matches.value_of("minutes") { - i6::timer::create::create_timer(minutes, ""); - } + if let Some(matches) = matches.subcommand_matches("timer") { + if let Some(matches) = matches.subcommand_matches("create") { + let minutes = matches.value_of("minutes").unwrap_or_default(); + let name = matches.value_of("name").unwrap_or_default(); + i6::timer::create::create_timer(minutes, name); + } else if matches.subcommand_matches("list").is_some() { + i6::timer::list::list_timers(); + } else if let Some(matches) = matches.subcommand_matches("stop") { + if matches.is_present("all") { + i6::timer::stop::stop_all_timers(); + } else { + i6::timer::stop::stop_timer( + matches.value_of("name").unwrap_or_default(), + ); + } + } else if let Some(matches) = matches.subcommand_matches("history") { + if matches.is_present("json") { + i6::timer::print::print_history_json(); + } else { + i6::timer::print::print_history(); + } + } else if let (Some(minutes), Some(name)) = + (matches.value_of("minutes"), matches.value_of("name")) + { + i6::timer::create::create_timer(minutes, name); + } else if let Some(minutes) = matches.value_of("minutes") { + i6::timer::create::create_timer(minutes, ""); } + } } From 2ba1c5b0832aa7b5c2aa877cddac8bb63edef18d Mon Sep 17 00:00:00 2001 From: kruserr <46799551+kruserr@users.noreply.github.com> Date: Sun, 17 Mar 2024 11:47:28 +0000 Subject: [PATCH 4/7] feat: http and https commands --- Cargo.lock | 1416 +++++++++++++++++++++++++++++++++++++++++++++-- Cargo.toml | 11 + src/http/mod.rs | 101 ++++ src/lib.rs | 1 + src/main.rs | 35 +- 5 files changed, 1527 insertions(+), 37 deletions(-) create mode 100644 src/http/mod.rs diff --git a/Cargo.lock b/Cargo.lock index 3764a57..1d0d19e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,13 +2,39 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "addr2line" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + +[[package]] +name = "async-trait" +version = "0.1.78" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "461abc97219de0eaaf81fe3ef974a540158f3d079c2ab200f891f1a2ef201e85" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "atty" version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" dependencies = [ - "hermit-abi", + "hermit-abi 0.1.19", "libc", "winapi", ] @@ -19,12 +45,72 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +[[package]] +name = "backtrace" +version = "0.3.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + +[[package]] +name = "base64" +version = "0.21.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" + [[package]] name = "bitflags" version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "bytes" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" + +[[package]] +name = "cc" +version = "1.0.90" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + [[package]] name = "clap" version = "3.2.25" @@ -32,9 +118,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123" dependencies = [ "atty", - "bitflags", + "bitflags 1.3.2", "clap_lex", - "indexmap", + "indexmap 1.9.3", "strsim", "termcolor", "textwrap", @@ -49,12 +135,210 @@ dependencies = [ "os_str_bytes", ] +[[package]] +name = "cpufeatures" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" +dependencies = [ + "libc", +] + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "data-encoding" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e962a19be5cfc3f3bf6dd8f61eb50107f356ad6270fbb3ed41476571db78be5" + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "crypto-common", +] + +[[package]] +name = "encoding_rs" +version = "0.8.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7268b386296a025e474d5140678f75d6de9493ae55a5d709eeb9dd08149945e1" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + +[[package]] +name = "form_urlencoded" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "futures-channel" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" + +[[package]] +name = "futures-sink" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" + +[[package]] +name = "futures-task" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" + +[[package]] +name = "futures-util" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" +dependencies = [ + "futures-core", + "futures-sink", + "futures-task", + "pin-project-lite", + "pin-utils", + "slab", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "gimli" +version = "0.28.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" + +[[package]] +name = "h2" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fbd2820c5e49886948654ab546d0688ff24530286bdcf8fca3cefb16d4618eb" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap 2.2.5", + "slab", + "tokio", + "tokio-util", + "tracing", +] + [[package]] name = "hashbrown" version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +[[package]] +name = "hashbrown" +version = "0.14.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" + +[[package]] +name = "headers" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06683b93020a07e3dbcf5f8c0f6d40080d725bea7936fc01ad345c01b97dc270" +dependencies = [ + "base64", + "bytes", + "headers-core", + "http", + "httpdate", + "mime", + "sha1", +] + +[[package]] +name = "headers-core" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7f66481bfee273957b1f20485a4ff3362987f85b2c236580d81b4eb7a326429" +dependencies = [ + "http", +] + [[package]] name = "hermit-abi" version = "0.1.19" @@ -64,11 +348,90 @@ dependencies = [ "libc", ] +[[package]] +name = "hermit-abi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" + +[[package]] +name = "http" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" +dependencies = [ + "bytes", + "http", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" + +[[package]] +name = "httpdate" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" + +[[package]] +name = "hyper" +version = "0.14.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf96e135eb83a2a8ddf766e426a841d8ddd7449d5f00d34ea02b41d2f19eef80" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", + "want", +] + [[package]] name = "i6" version = "0.1.5" dependencies = [ "clap", + "openssl", + "rapiddb-web", + "tokio", + "tracing-subscriber", + "warp", +] + +[[package]] +name = "idna" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" +dependencies = [ + "unicode-bidi", + "unicode-normalization", ] [[package]] @@ -78,9 +441,31 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" dependencies = [ "autocfg", - "hashbrown", + "hashbrown 0.12.3", +] + +[[package]] +name = "indexmap" +version = "2.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b0b929d511467233429c45a44ac1dcaa21ba0f5ba11e4879e6ed28ddb4f9df4" +dependencies = [ + "equivalent", + "hashbrown 0.14.3", ] +[[package]] +name = "itoa" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + [[package]] name = "libc" version = "0.2.153" @@ -88,59 +473,1028 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] -name = "os_str_bytes" -version = "6.6.1" +name = "lock_api" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2355d85b9a3786f481747ced0e0ff2ba35213a1f9bd406ed906554d7af805a1" +checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" +dependencies = [ + "autocfg", + "scopeguard", +] [[package]] -name = "strsim" -version = "0.10.0" +name = "log" +version = "0.4.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" [[package]] -name = "termcolor" -version = "1.4.1" +name = "memchr" +version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" +checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" + +[[package]] +name = "memmap2" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe751422e4a8caa417e13c3ea66452215d7d63e19e604f4980461212f3ae1322" dependencies = [ - "winapi-util", + "libc", ] [[package]] -name = "textwrap" -version = "0.16.1" +name = "mime" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23d434d3f8967a09480fb04132ebe0a3e088c173e6d0ee7897abbdf4eab0f8b9" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" [[package]] -name = "winapi" -version = "0.3.9" +name = "mime_guess" +version = "2.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +checksum = "4192263c238a5f0d0c6bfd21f336a313a4ce1c450542449ca191bb657b4642ef" dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", + "mime", + "unicase", ] [[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" +name = "miniz_oxide" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" +dependencies = [ + "adler", +] [[package]] -name = "winapi-util" -version = "0.1.6" +name = "mio" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" +checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" +dependencies = [ + "libc", + "wasi", + "windows-sys 0.48.0", +] + +[[package]] +name = "multer" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01acbdc23469fd8fe07ab135923371d5f5a422fbf9c522158677c8eb15bc51c2" +dependencies = [ + "bytes", + "encoding_rs", + "futures-util", + "http", + "httparse", + "log", + "memchr", + "mime", + "spin", + "version_check", +] + +[[package]] +name = "nu-ansi-term" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" dependencies = [ + "overload", "winapi", ] [[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" +name = "num_cpus" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" +dependencies = [ + "hermit-abi 0.3.9", + "libc", +] + +[[package]] +name = "object" +version = "0.32.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" +dependencies = [ + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + +[[package]] +name = "openssl" +version = "0.10.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95a0481286a310808298130d22dd1fef0fa571e05a8f44ec801801e84b216b1f" +dependencies = [ + "bitflags 2.4.2", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "openssl-sys" +version = "0.9.101" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dda2b0f344e78efc2facf7d195d098df0dd72151b26ab98da807afc26c198dff" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "os_str_bytes" +version = "6.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2355d85b9a3786f481747ced0e0ff2ba35213a1f9bd406ed906554d7af805a1" + +[[package]] +name = "overload" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" + +[[package]] +name = "parking_lot" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-targets 0.48.5", +] + +[[package]] +name = "percent-encoding" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" + +[[package]] +name = "pin-project" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "pkg-config" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" + +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "proc-macro2" +version = "1.0.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "rapiddb" +version = "0.1.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26c574402b26e2a8a73108785058843fba909e4145cb2fd5ad44a64a7898c620" +dependencies = [ + "async-trait", + "memmap2", + "serde", + "serde_json", + "tokio", +] + +[[package]] +name = "rapiddb-web" +version = "0.1.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8e8264f60ce40db8aa3ff394d4fa08d4d8937353d2048cc971f254de633f0fc" +dependencies = [ + "rapiddb", + "serde", + "serde_json", + "tokio", + "warp", +] + +[[package]] +name = "redox_syscall" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" +dependencies = [ + "bitflags 1.3.2", +] + +[[package]] +name = "ring" +version = "0.17.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" +dependencies = [ + "cc", + "cfg-if", + "getrandom", + "libc", + "spin", + "untrusted", + "windows-sys 0.52.0", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" + +[[package]] +name = "rustls" +version = "0.21.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9d5a6813c0759e4609cd494e8e725babae6a2ca7b62a5536a13daaec6fcb7ba" +dependencies = [ + "log", + "ring", + "rustls-webpki", + "sct", +] + +[[package]] +name = "rustls-pemfile" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" +dependencies = [ + "base64", +] + +[[package]] +name = "rustls-webpki" +version = "0.101.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "ryu" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" + +[[package]] +name = "scoped-tls" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "sct" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "serde" +version = "1.0.197" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.197" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.114" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c5f09b1bd632ef549eaa9f60a1f8de742bdbc698e6cee2095fc84dde5f549ae0" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sha1" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "sharded-slab" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "signal-hook-registry" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" +dependencies = [ + "libc", +] + +[[package]] +name = "slab" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" +dependencies = [ + "autocfg", +] + +[[package]] +name = "smallvec" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" + +[[package]] +name = "socket2" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05ffd9c0a93b7543e062e759284fcf5f5e3b098501104bfbdde4d404db792871" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" + +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + +[[package]] +name = "syn" +version = "2.0.53" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7383cd0e49fff4b6b90ca5670bfd3e9d6a733b3f90c686605aa7eec8c4996032" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "termcolor" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "textwrap" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23d434d3f8967a09480fb04132ebe0a3e088c173e6d0ee7897abbdf4eab0f8b9" + +[[package]] +name = "thiserror" +version = "1.0.58" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.58" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "thread_local" +version = "1.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c" +dependencies = [ + "cfg-if", + "once_cell", +] + +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "tokio" +version = "1.36.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61285f6515fa018fb2d1e46eb21223fff441ee8db5d0f1435e8ab4f5cdb80931" +dependencies = [ + "backtrace", + "bytes", + "libc", + "mio", + "num_cpus", + "parking_lot", + "pin-project-lite", + "signal-hook-registry", + "socket2", + "tokio-macros", + "windows-sys 0.48.0", +] + +[[package]] +name = "tokio-macros" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tokio-rustls" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" +dependencies = [ + "rustls", + "tokio", +] + +[[package]] +name = "tokio-stream" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "267ac89e0bec6e691e5813911606935d77c476ff49024f98abcea3e7b15e37af" +dependencies = [ + "futures-core", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tokio-tungstenite" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "212d5dcb2a1ce06d81107c3d0ffa3121fe974b73f068c8282cb1c32328113b6c" +dependencies = [ + "futures-util", + "log", + "tokio", + "tungstenite", +] + +[[package]] +name = "tokio-util" +version = "0.7.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", + "tracing", +] + +[[package]] +name = "tower-service" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" + +[[package]] +name = "tracing" +version = "0.1.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +dependencies = [ + "log", + "pin-project-lite", + "tracing-core", +] + +[[package]] +name = "tracing-core" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +dependencies = [ + "once_cell", + "valuable", +] + +[[package]] +name = "tracing-log" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" +dependencies = [ + "log", + "once_cell", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" +dependencies = [ + "nu-ansi-term", + "sharded-slab", + "smallvec", + "thread_local", + "tracing-core", + "tracing-log", +] + +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + +[[package]] +name = "tungstenite" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e3dac10fd62eaf6617d3a904ae222845979aec67c615d1c842b4002c7666fb9" +dependencies = [ + "byteorder", + "bytes", + "data-encoding", + "http", + "httparse", + "log", + "rand", + "sha1", + "thiserror", + "url", + "utf-8", +] + +[[package]] +name = "typenum" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" + +[[package]] +name = "unicase" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7d2d4dafb69621809a81864c9c1b864479e1235c0dd4e199924b9742439ed89" +dependencies = [ + "version_check", +] + +[[package]] +name = "unicode-bidi" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "unicode-normalization" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + +[[package]] +name = "url" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + +[[package]] +name = "utf-8" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" + +[[package]] +name = "valuable" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + +[[package]] +name = "warp" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1e92e22e03ff1230c03a1a8ee37d2f89cd489e2e541b7550d6afad96faed169" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "headers", + "http", + "hyper", + "log", + "mime", + "mime_guess", + "multer", + "percent-encoding", + "pin-project", + "rustls-pemfile", + "scoped-tls", + "serde", + "serde_json", + "serde_urlencoded", + "tokio", + "tokio-rustls", + "tokio-stream", + "tokio-tungstenite", + "tokio-util", + "tower-service", + "tracing", +] + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" +dependencies = [ + "winapi", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.4", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dd37b7e5ab9018759f893a1952c9420d060016fc19a472b4bb20d1bdd694d1b" +dependencies = [ + "windows_aarch64_gnullvm 0.52.4", + "windows_aarch64_msvc 0.52.4", + "windows_i686_gnu 0.52.4", + "windows_i686_msvc 0.52.4", + "windows_x86_64_gnu 0.52.4", + "windows_x86_64_gnullvm 0.52.4", + "windows_x86_64_msvc 0.52.4", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcf46cf4c365c6f2d1cc93ce535f2c8b244591df96ceee75d8e83deb70a9cac9" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da9f259dd3bcf6990b55bffd094c4f7235817ba4ceebde8e6d11cd0c5633b675" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b474d8268f99e0995f25b9f095bc7434632601028cf86590aea5c8a5cb7801d3" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1515e9a29e5bed743cb4415a9ecf5dfca648ce85ee42e15873c3cd8610ff8e02" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5eee091590e89cc02ad514ffe3ead9eb6b660aedca2183455434b93546371a03" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77ca79f2451b49fa9e2af39f0747fe999fcda4f5e241b2898624dca97a1f2177" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8" diff --git a/Cargo.toml b/Cargo.toml index 3bdc31f..a7ff4fc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,3 +12,14 @@ categories = ["command-line-interface", "command-line-utilities", "development-t [dependencies] clap = "3" + +# for http and https commands +tokio = { version = "1", features = ["full"] } +# warp = "0.3" +# for https command +warp = { version = "0.3", features = ["default", "tls"] } +openssl = "0.10" + +# for db command +rapiddb-web = "0.1" +tracing-subscriber = "0.3.18" diff --git a/src/http/mod.rs b/src/http/mod.rs new file mode 100644 index 0000000..4ab0737 --- /dev/null +++ b/src/http/mod.rs @@ -0,0 +1,101 @@ +use openssl::hash::MessageDigest; +use openssl::pkey::PKey; +use openssl::rsa::Rsa; +use openssl::x509::extension::BasicConstraints; +use openssl::x509::{X509NameBuilder, X509}; +use tracing_subscriber::fmt::format::FmtSpan; +use warp::Filter; +use std::error::Error; +use std::fs::{File, OpenOptions}; +use std::io::Write; +use std::path::Path; + +pub fn open_or_create_file(path: &str) -> Result> { + let path = Path::new(path); + + if let Some(parent) = path.parent() { + std::fs::create_dir_all(parent)?; + } + + let file = OpenOptions::new() + .read(true) + .write(true) + .create(true) + .open(path)?; + + Ok(file) +} + +pub fn generate_openssl_x509_rsa_cert_key_files(cert_file_path: &str, key_file_path: &str) -> Result<(), Box> { + let rsa = Rsa::generate(2048)?; + let pkey = PKey::from_rsa(rsa)?; + + let mut name = X509NameBuilder::new()?; + name.append_entry_by_text("CN", "localhost")?; + let name = name.build(); + + let mut builder = X509::builder()?; + builder.set_version(2)?; + builder.set_subject_name(&name)?; + builder.set_issuer_name(&name)?; + builder.set_pubkey(&pkey)?; + builder + .set_not_before(&*openssl::asn1::Asn1Time::days_from_now(0)?) + ?; + builder + .set_not_after(&*openssl::asn1::Asn1Time::days_from_now(3650)?) + ?; + + builder + .append_extension( + BasicConstraints::new().critical().ca().build()?, + ) + ?; + + builder.sign(&pkey, MessageDigest::sha256())?; + + let certificate = builder.build(); + + let mut key_file = open_or_create_file(key_file_path)?; + key_file.write_all(&pkey.private_key_to_pem_pkcs8()?)?; + + let mut cert_file = open_or_create_file(cert_file_path)?; + cert_file.write_all(&certificate.to_pem()?)?; + + return Ok(()); +} + +pub async fn create_server_http(port: u16) -> Result<(), Box> { + tracing_subscriber::fmt().with_span_events(FmtSpan::CLOSE).init(); + + warp::serve(warp::fs::dir(".").with(warp::trace::request())) + .run(([0, 0, 0, 0], port)) + .await; + + return Ok(()); +} + +pub async fn create_server_https(port: u16) -> Result<(), Box> { + let key_file_path = &format!( + "{}/d4cd362e-89ef-4267-9e35-4cc8a79b60eb/key.pem", + std::env::temp_dir().to_str().unwrap_or(".") + ); + + let cert_file_path = &format!( + "{}/d4cd362e-89ef-4267-9e35-4cc8a79b60eb/cert.pem", + std::env::temp_dir().to_str().unwrap_or(".") + ); + + generate_openssl_x509_rsa_cert_key_files(cert_file_path, key_file_path)?; + + tracing_subscriber::fmt().with_span_events(FmtSpan::CLOSE).init(); + + warp::serve(warp::fs::dir(".").with(warp::trace::request())) + .tls() + .cert_path(cert_file_path) + .key_path(key_file_path) + .run(([0, 0, 0, 0], port)) + .await; + + return Ok(()); +} diff --git a/src/lib.rs b/src/lib.rs index 783fd9e..36b334f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -54,3 +54,4 @@ //! ``` pub mod timer; +pub mod http; diff --git a/src/main.rs b/src/main.rs index fec203d..945e499 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,15 +1,28 @@ -use clap::{App, Arg, SubCommand}; +use std::error::Error; -fn main() { +use clap::{value_parser, App, Arg, SubCommand}; + +#[tokio::main] +async fn main() -> Result<(), Box> { let http_id = "http"; let https_id = "https"; let matches = App::new("i6") .subcommand( - SubCommand::with_name(http_id).about("Start a static http server"), + SubCommand::with_name(http_id).about("Start a static http server").arg( + Arg::with_name("port") + .index(1) + .default_value("3030") + .value_parser(value_parser!(u16)), + ), ) .subcommand( - SubCommand::with_name(https_id).about("Start a static https server"), + SubCommand::with_name(https_id).about("Start a static https server").arg( + Arg::with_name("port") + .index(1) + .default_value("3030") + .value_parser(value_parser!(u16)), + ), ) .subcommand( SubCommand::with_name("timer") @@ -71,11 +84,19 @@ fn main() { .get_matches(); if let Some(matches) = matches.subcommand_matches(http_id) { - println!("http"); + println!("http, {:?}", matches); + + let port = *matches.get_one::("port").unwrap_or(&3030); + + i6::http::create_server_http(port).await?; } if let Some(matches) = matches.subcommand_matches(https_id) { - println!("https"); + println!("https, {:?}", matches); + + let port = *matches.get_one::("port").unwrap_or(&3030); + + i6::http::create_server_https(port).await?; } if let Some(matches) = matches.subcommand_matches("timer") { @@ -107,4 +128,6 @@ fn main() { i6::timer::create::create_timer(minutes, ""); } } + + return Ok(()); } From 03171734b8a8193d48501f407c8071ee5dd7ece8 Mon Sep 17 00:00:00 2001 From: kruserr <46799551+kruserr@users.noreply.github.com> Date: Sun, 17 Mar 2024 11:48:00 +0000 Subject: [PATCH 5/7] build: organize deps --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index a7ff4fc..e502d6d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,10 +16,10 @@ clap = "3" # for http and https commands tokio = { version = "1", features = ["full"] } # warp = "0.3" +tracing-subscriber = "0.3.18" # for https command warp = { version = "0.3", features = ["default", "tls"] } openssl = "0.10" # for db command rapiddb-web = "0.1" -tracing-subscriber = "0.3.18" From 5b07adec38b3941a2c49a38b10eff88116b6d832 Mon Sep 17 00:00:00 2001 From: kruserr <46799551+kruserr@users.noreply.github.com> Date: Sun, 17 Mar 2024 11:55:09 +0000 Subject: [PATCH 6/7] ci: allow unused parens and needles return --- Cargo.toml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index e502d6d..080f599 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,3 +23,9 @@ openssl = "0.10" # for db command rapiddb-web = "0.1" + +[lints.rust] +unused_parens = "allow" + +[lints.clippy] +needless_return = "allow" From f959086203704f15f2504c03239a70ce74ac84f4 Mon Sep 17 00:00:00 2001 From: kruserr <46799551+kruserr@users.noreply.github.com> Date: Sun, 17 Mar 2024 11:55:15 +0000 Subject: [PATCH 7/7] style: fmt --- src/http/mod.rs | 74 ++++++++++++++++++++++--------------------------- src/lib.rs | 2 +- 2 files changed, 34 insertions(+), 42 deletions(-) diff --git a/src/http/mod.rs b/src/http/mod.rs index 4ab0737..c873ebd 100644 --- a/src/http/mod.rs +++ b/src/http/mod.rs @@ -3,66 +3,58 @@ use openssl::pkey::PKey; use openssl::rsa::Rsa; use openssl::x509::extension::BasicConstraints; use openssl::x509::{X509NameBuilder, X509}; -use tracing_subscriber::fmt::format::FmtSpan; -use warp::Filter; use std::error::Error; use std::fs::{File, OpenOptions}; use std::io::Write; use std::path::Path; +use tracing_subscriber::fmt::format::FmtSpan; +use warp::Filter; pub fn open_or_create_file(path: &str) -> Result> { - let path = Path::new(path); + let path = Path::new(path); - if let Some(parent) = path.parent() { - std::fs::create_dir_all(parent)?; - } + if let Some(parent) = path.parent() { + std::fs::create_dir_all(parent)?; + } - let file = OpenOptions::new() - .read(true) - .write(true) - .create(true) - .open(path)?; + let file = + OpenOptions::new().read(true).write(true).create(true).open(path)?; - Ok(file) + Ok(file) } -pub fn generate_openssl_x509_rsa_cert_key_files(cert_file_path: &str, key_file_path: &str) -> Result<(), Box> { - let rsa = Rsa::generate(2048)?; - let pkey = PKey::from_rsa(rsa)?; +pub fn generate_openssl_x509_rsa_cert_key_files( + cert_file_path: &str, + key_file_path: &str, +) -> Result<(), Box> { + let rsa = Rsa::generate(2048)?; + let pkey = PKey::from_rsa(rsa)?; - let mut name = X509NameBuilder::new()?; - name.append_entry_by_text("CN", "localhost")?; - let name = name.build(); + let mut name = X509NameBuilder::new()?; + name.append_entry_by_text("CN", "localhost")?; + let name = name.build(); - let mut builder = X509::builder()?; - builder.set_version(2)?; - builder.set_subject_name(&name)?; - builder.set_issuer_name(&name)?; - builder.set_pubkey(&pkey)?; - builder - .set_not_before(&*openssl::asn1::Asn1Time::days_from_now(0)?) - ?; - builder - .set_not_after(&*openssl::asn1::Asn1Time::days_from_now(3650)?) - ?; + let mut builder = X509::builder()?; + builder.set_version(2)?; + builder.set_subject_name(&name)?; + builder.set_issuer_name(&name)?; + builder.set_pubkey(&pkey)?; + builder.set_not_before(&*openssl::asn1::Asn1Time::days_from_now(0)?)?; + builder.set_not_after(&*openssl::asn1::Asn1Time::days_from_now(3650)?)?; - builder - .append_extension( - BasicConstraints::new().critical().ca().build()?, - ) - ?; + builder.append_extension(BasicConstraints::new().critical().ca().build()?)?; - builder.sign(&pkey, MessageDigest::sha256())?; + builder.sign(&pkey, MessageDigest::sha256())?; - let certificate = builder.build(); + let certificate = builder.build(); - let mut key_file = open_or_create_file(key_file_path)?; - key_file.write_all(&pkey.private_key_to_pem_pkcs8()?)?; + let mut key_file = open_or_create_file(key_file_path)?; + key_file.write_all(&pkey.private_key_to_pem_pkcs8()?)?; - let mut cert_file = open_or_create_file(cert_file_path)?; - cert_file.write_all(&certificate.to_pem()?)?; + let mut cert_file = open_or_create_file(cert_file_path)?; + cert_file.write_all(&certificate.to_pem()?)?; - return Ok(()); + return Ok(()); } pub async fn create_server_http(port: u16) -> Result<(), Box> { diff --git a/src/lib.rs b/src/lib.rs index 36b334f..a1ce2cd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -53,5 +53,5 @@ //! i6 //! ``` -pub mod timer; pub mod http; +pub mod timer;