From 2ccb9fc4fcc85291d50fbbd88fdda735f5e091d6 Mon Sep 17 00:00:00 2001 From: zephyr Date: Fri, 15 Apr 2022 00:04:18 +0900 Subject: [PATCH] support client-side mask strategies: [skip, standard, fixed] --- Cargo.lock | 47 ++++++++++++----------------------------------- cmd/Cargo.toml | 4 ++-- cmd/src/client.rs | 26 ++++++++++++++++++++++++-- 3 files changed, 38 insertions(+), 39 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5aba9a8..f03b9e0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -129,14 +129,12 @@ dependencies = [ [[package]] name = "kaminari" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df2ca3de88447dc338247c2c71c9b710c83b056dbc11fcf87b3a3fa05db455e0" +version = "0.5.3" dependencies = [ "lazy_static", - "lightws 0.4.5", + "lightws", "rcgen", - "rustls-pemfile 0.3.0", + "rustls-pemfile", "tokio", "tokio-rustls", "webpki-roots", @@ -144,12 +142,14 @@ dependencies = [ [[package]] name = "kaminari" -version = "0.5.0" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b26f0fb6b65f2c8304d17d6f2fd76d4b4a081d7683ea6664905299cc7bd1edf" dependencies = [ "lazy_static", - "lightws 0.6.1", + "lightws", "rcgen", - "rustls-pemfile 1.0.0", + "rustls-pemfile", "tokio", "tokio-rustls", "webpki-roots", @@ -157,10 +157,10 @@ dependencies = [ [[package]] name = "kaminari-cmd" -version = "0.3.2" +version = "0.4.0" dependencies = [ "anyhow", - "kaminari 0.4.1", + "kaminari 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "tokio", ] @@ -178,23 +178,9 @@ checksum = "efaa7b300f3b5fe8eb6bf21ce3895e1751d9665086af2d64b42f19701015ff4f" [[package]] name = "lightws" -version = "0.4.5" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73223fefcf168b791b55b0d0a75605141993c3cdfed47cd65f3773ce6c4bb74f" -dependencies = [ - "base64 0.20.0-alpha.1", - "cfg-if", - "httparse", - "rand", - "sha1", - "tokio", -] - -[[package]] -name = "lightws" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1df0458f49d9e8e108609aa6fefe7ef47715551ba94f7455a1b7db656306d72c" +checksum = "94010c166164a0e47aceb5bba8d2b62ed5a29578826c419c40c3f47191d9036a" dependencies = [ "base64 0.20.0-alpha.1", "cfg-if", @@ -384,15 +370,6 @@ dependencies = [ "webpki", ] -[[package]] -name = "rustls-pemfile" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ee86d63972a7c661d1536fefe8c3c8407321c3df668891286de28abcd087360" -dependencies = [ - "base64 0.13.0", -] - [[package]] name = "rustls-pemfile" version = "1.0.0" diff --git a/cmd/Cargo.toml b/cmd/Cargo.toml index 981f34e..905fc82 100644 --- a/cmd/Cargo.toml +++ b/cmd/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "kaminari-cmd" -version = "0.3.2" +version = "0.4.0" edition = "2021" authors = ["zephyr "] repository = "https://github.com/zephyrchien/kaminari/cmd" @@ -9,7 +9,7 @@ readme = "README.md" license = "GPL-3.0" [dependencies] -kaminari = "0.4.1" +kaminari = "0.5.3" tokio = { version = "1", features = ["net", "macros", "rt-multi-thread", "io-util"] } anyhow = "1" diff --git a/cmd/src/client.rs b/cmd/src/client.rs index 0b93b82..8d578d1 100644 --- a/cmd/src/client.rs +++ b/cmd/src/client.rs @@ -38,6 +38,28 @@ async fn main() -> Result<()> { }; } + macro_rules! run_ws_each { + ($client: expr) => { + let ws_mask_mode = opt::get_opt!(&options => "mask"); + match ws_mask_mode { + Some("standard") => { + eprintln!("mask: standard"); + let client = $client.standard(); + run!(Ref::new(&client)); + }, + Some("fixed") => { + let client = $client.fixed(); + eprintln!("mask: fixed"); + run!(Ref::new(&client)); + }, + _ => { + eprintln!("mask: skip"); + run!(Ref::new(&$client)); + } + }; + } + } + match (ws, tls) { (None, None) => { let client = NopConnect {}; @@ -45,7 +67,7 @@ async fn main() -> Result<()> { } (Some(ws), None) => { let client = WsConnect::new(NopConnect {}, ws); - run!(Ref::new(&client)); + run_ws_each!(client); } (None, Some(tls)) => { let client = TlsConnect::new(NopConnect {}, tls); @@ -53,7 +75,7 @@ async fn main() -> Result<()> { } (Some(ws), Some(tls)) => { let client = WsConnect::new(TlsConnect::new(NopConnect {}, tls), ws); - run!(Ref::new(&client)); + run_ws_each!(client); } }; }