Update to 1.21.10
This commit is contained in:
parent
8ae9635c80
commit
fc2186fc32
1027
Cargo.lock
generated
1027
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -10,14 +10,14 @@ codegen-units = 1
|
||||
[dependencies]
|
||||
# log
|
||||
log = "0.4"
|
||||
simple_logger = "5.0.0"
|
||||
simple_logger = "5.1.0"
|
||||
# CLI
|
||||
clap = { version = "4.5.42", features = ["derive"] }
|
||||
clap = { version = "4.5.53", features = ["derive"] }
|
||||
# Networking
|
||||
tokio = { version = "1.47.1", features = ["net", "io-util"] }
|
||||
tokio = { version = "1.48.0", features = ["net", "io-util"] }
|
||||
pumpkin-protocol = { git = "https://github.com/Pumpkin-MC/Pumpkin", package = "pumpkin-protocol", default-features = false, features = ["serverbound", "clientbound"]}
|
||||
pumpkin-data = { git = "https://github.com/Pumpkin-MC/Pumpkin", package = "pumpkin-data"}
|
||||
|
||||
crossbeam = "0.8.4"
|
||||
uuid = "1.17.0"
|
||||
uuid = "1.19.0"
|
||||
rand = "0.9"
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<div align="center">
|
||||
|
||||
[](https://opensource.org/licenses/MIT)
|
||||

|
||||

|
||||
|
||||
A tool to stress test Minecraft servers by simulating numerous bot connections, helping identify performance bottlenecks and stability issues.
|
||||

|
||||
@ -35,6 +35,10 @@ Here's a detailed breakdown of all available command-line arguments:
|
||||
- The delay (in milliseconds) between each bot connection.
|
||||
- Example: `--delay 100` (100 milliseconds delay)
|
||||
|
||||
- **`-t, --timeout <delay>` (Optional, Default: `5000`):**
|
||||
- The timeout (in milliseconds) for each bot connection.
|
||||
- Example: `--delay 500` (500 milliseconds delay)
|
||||
|
||||
- **`--spam_message "<message>"` (Optional):**
|
||||
- Will send a Chat message with the specefied `spam_message_delay`.
|
||||
- Example: `--spam_message "Hello, I'm a Robot"`
|
||||
|
||||
@ -139,16 +139,15 @@ impl Client {
|
||||
if self.connection_state.load() != ConnectionState::Play {
|
||||
return;
|
||||
}
|
||||
if let Some(spam_message) = spam_message.as_ref() {
|
||||
if self
|
||||
if let Some(spam_message) = spam_message.as_ref()
|
||||
&& self
|
||||
.message_spam_cooldown
|
||||
.fetch_sub(1, std::sync::atomic::Ordering::Relaxed)
|
||||
== 0
|
||||
{
|
||||
self.message_spam_cooldown
|
||||
.store(spam_message_delay, std::sync::atomic::Ordering::Relaxed);
|
||||
self.send_message(spam_message.clone()).await
|
||||
}
|
||||
{
|
||||
self.message_spam_cooldown
|
||||
.store(spam_message_delay, std::sync::atomic::Ordering::Relaxed);
|
||||
self.send_message(spam_message.clone()).await
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
35
src/main.rs
35
src/main.rs
@ -2,7 +2,7 @@ use std::{net::SocketAddr, sync::Arc, thread::sleep, time::Duration};
|
||||
|
||||
use clap::Parser;
|
||||
use client::Client;
|
||||
use tokio::net::TcpStream;
|
||||
use tokio::{net::TcpStream, time::timeout};
|
||||
|
||||
mod client;
|
||||
|
||||
@ -10,11 +10,13 @@ mod client;
|
||||
#[command(version, about, long_about = None)]
|
||||
pub struct Args {
|
||||
#[arg(long)]
|
||||
ip: String,
|
||||
pub ip: String,
|
||||
#[arg(short, long, default_value_t = 1)]
|
||||
count: u32,
|
||||
pub count: u32,
|
||||
#[arg(short, long, default_value_t = 200)]
|
||||
delay: u64,
|
||||
pub delay: u64,
|
||||
#[arg(short, long, default_value_t = 5000)]
|
||||
pub timeout: u64,
|
||||
#[arg(long)]
|
||||
pub spam_message: Option<String>,
|
||||
#[arg(long, default_value_t = 210)]
|
||||
@ -35,9 +37,28 @@ async fn main() {
|
||||
let mut join_handles = Vec::with_capacity(args.count as usize);
|
||||
for i in 0..args.count {
|
||||
sleep(Duration::from_millis(args.delay));
|
||||
let stream = TcpStream::connect(address)
|
||||
.await
|
||||
.expect("Failed to connect to Ip");
|
||||
let stream_result = timeout(
|
||||
Duration::from_millis(args.timeout),
|
||||
TcpStream::connect(address),
|
||||
)
|
||||
.await;
|
||||
|
||||
let stream = match stream_result {
|
||||
Ok(Ok(s)) => s,
|
||||
Ok(Err(e)) => {
|
||||
log::error!("Bot {} failed to connect to {}: {}", i + 1, address, e);
|
||||
continue;
|
||||
}
|
||||
Err(_) => {
|
||||
log::error!(
|
||||
"Bot {} connection to {} timed out after {}ms",
|
||||
i + 1,
|
||||
address,
|
||||
args.timeout
|
||||
);
|
||||
continue;
|
||||
}
|
||||
};
|
||||
let client = Arc::new(Client::new(stream));
|
||||
let message = Arc::new(args.spam_message.clone());
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user