add new game spam

This commit is contained in:
Adam 2024-10-09 02:20:03 -04:00
parent 3fc4237fcc
commit 43e312445b
3 changed files with 39 additions and 1 deletions

3
Cargo.lock generated
View file

@ -2468,6 +2468,9 @@ name = "socket_blaster"
version = "0.1.0"
dependencies = [
"clap",
"lib",
"serde",
"serde_json",
"tungstenite",
]

View file

@ -6,3 +6,6 @@ edition = "2021"
[dependencies]
clap = { version = "4", features = ["cargo"] }
tungstenite = "0"
lib = { workspace = true }
serde_json = "1"
serde = { version = "1", features = ["derive"] }

View file

@ -1,22 +1,54 @@
use std::collections::HashSet;
use clap::{command, Command};
use tungstenite::connect;
use lib::*;
use serde_json::to_string;
use tungstenite::{connect, Message};
/// 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");
}
}
/// Infinite loop that creates games
fn spam_games() {
println!("Spamming game creation");
let mut packs = HashSet::new();
for pack in 0..205 {
packs.insert(pack.to_string());
}
let (mut socket, _) = connect("ws://127.0.0.1:3030/websocket").expect("Can't connect");
loop {
socket
.send(Message::Text(
to_string(&NewGameRequest {
name: "ligma".to_string(),
packs: packs.clone(),
})
.unwrap(),
))
.unwrap();
}
}
fn main() {
let matches = command!()
.subcommand(
Command::new("zombies")
.about("Infinite loop spawning new user connections and then leaving them open."),
)
.subcommand(Command::new("games").about("Infinite loop that creates games."))
.get_matches();
if matches.subcommand_matches("zombies").is_some() {
zombie_horde();
} else if matches.subcommand_matches("games").is_some() {
spam_games();
}
}