diff --git a/Cargo.lock b/Cargo.lock index 198c077..b5910a8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -56,6 +56,55 @@ dependencies = [ "libc", ] +[[package]] +name = "anstream" +version = "0.6.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64e15c1ab1f89faffbf04a634d5e1962e9074f2741eef6d97f3c4e322426d526" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1" + +[[package]] +name = "anstyle-parse" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb47de1e80c2b463c735db5b217a0ddc39d612e7ac9e2e96a5aed1f57616c1cb" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a" +dependencies = [ + "windows-sys 0.52.0", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8" +dependencies = [ + "anstyle", + "windows-sys 0.52.0", +] + [[package]] name = "any_spawner" version = "0.1.1" @@ -332,6 +381,33 @@ dependencies = [ "windows-targets", ] +[[package]] +name = "clap" +version = "4.5.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b97f376d85a664d5837dbae44bf546e6477a679ff6610010f17276f686d867e8" +dependencies = [ + "clap_builder", +] + +[[package]] +name = "clap_builder" +version = "4.5.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19bc80abd44e4bed93ca373a0704ccbd1b710dc5749406201bb018272808dc54" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_lex" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97" + [[package]] name = "client" version = "0.1.0" @@ -370,6 +446,12 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "186dce98367766de751c42c4f03970fc60fc012296e706ccbb9d5df9b6c1e271" +[[package]] +name = "colorchoice" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0" + [[package]] name = "concurrent-queue" version = "2.5.0" @@ -1234,6 +1316,12 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "71dd52191aae121e8611f1e8dc3e324dd0dd1dee1e6dd91d10ee07a3cfb4d9d8" +[[package]] +name = "is_terminal_polyfill" +version = "1.70.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" + [[package]] name = "itertools" version = "0.13.0" @@ -2375,6 +2463,14 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "socket_blaster" +version = "0.1.0" +dependencies = [ + "clap", + "tungstenite", +] + [[package]] name = "strsim" version = "0.11.1" @@ -2931,6 +3027,12 @@ version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "86bd8d4e895da8537e5315b8254664e6b769c4ff3db18321b297a1e7004392e3" +[[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + [[package]] name = "uuid" version = "1.10.0" diff --git a/Cargo.toml b/Cargo.toml index bab4c09..618fcd6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [workspace] resolver = "2" -members = ["server", "client", "lib"] +members = ["server", "client", "lib", "tools/socket_blaster"] default-members = ["server", "lib"] [workspace.dependencies] diff --git a/test b/test index 2bce974..ac04955 100755 --- a/test +++ b/test @@ -1,3 +1,3 @@ #!/bin/sh -cargo watch -i client -cx run +cargo watch -i client/ -i tools/ -cx run diff --git a/tools/socket_blaster/Cargo.toml b/tools/socket_blaster/Cargo.toml new file mode 100644 index 0000000..20eda6d --- /dev/null +++ b/tools/socket_blaster/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "socket_blaster" +version = "0.1.0" +edition = "2021" + +[dependencies] +clap = { version = "4", features = ["cargo"] } +tungstenite = "0" diff --git a/tools/socket_blaster/src/main.rs b/tools/socket_blaster/src/main.rs new file mode 100644 index 0000000..3da9c4d --- /dev/null +++ b/tools/socket_blaster/src/main.rs @@ -0,0 +1,22 @@ +use clap::{command, Command}; +use tungstenite::connect; + +/// Infinite loop spawning new user connections and then leaving them open +fn zombie_horde() { + println!("Spamming new zombie user connections"); + loop { + let (_, _) = connect("ws://127.0.0.1:3030/websocket").expect("Can't connect"); + } +} +fn main() { + let matches = command!() + .subcommand( + Command::new("zombies") + .about("Infinite loop spawning new user connections and then leaving them open."), + ) + .get_matches(); + + if matches.subcommand_matches("zombies").is_some() { + zombie_horde(); + } +}