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]
|
[dependencies]
|
||||||
# log
|
# log
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
simple_logger = "5.0.0"
|
simple_logger = "5.1.0"
|
||||||
# CLI
|
# CLI
|
||||||
clap = { version = "4.5.42", features = ["derive"] }
|
clap = { version = "4.5.53", features = ["derive"] }
|
||||||
# Networking
|
# 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-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"}
|
pumpkin-data = { git = "https://github.com/Pumpkin-MC/Pumpkin", package = "pumpkin-data"}
|
||||||
|
|
||||||
crossbeam = "0.8.4"
|
crossbeam = "0.8.4"
|
||||||
uuid = "1.17.0"
|
uuid = "1.19.0"
|
||||||
rand = "0.9"
|
rand = "0.9"
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
<div align="center">
|
<div align="center">
|
||||||
|
|
||||||
[](https://opensource.org/licenses/MIT)
|
[](https://opensource.org/licenses/MIT)
|
||||||

|

|
||||||
|
|
||||||
A tool to stress test Minecraft servers by simulating numerous bot connections, helping identify performance bottlenecks and stability issues.
|
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.
|
- The delay (in milliseconds) between each bot connection.
|
||||||
- Example: `--delay 100` (100 milliseconds delay)
|
- 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):**
|
- **`--spam_message "<message>"` (Optional):**
|
||||||
- Will send a Chat message with the specefied `spam_message_delay`.
|
- Will send a Chat message with the specefied `spam_message_delay`.
|
||||||
- Example: `--spam_message "Hello, I'm a Robot"`
|
- Example: `--spam_message "Hello, I'm a Robot"`
|
||||||
|
|||||||
@ -139,8 +139,8 @@ impl Client {
|
|||||||
if self.connection_state.load() != ConnectionState::Play {
|
if self.connection_state.load() != ConnectionState::Play {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if let Some(spam_message) = spam_message.as_ref() {
|
if let Some(spam_message) = spam_message.as_ref()
|
||||||
if self
|
&& self
|
||||||
.message_spam_cooldown
|
.message_spam_cooldown
|
||||||
.fetch_sub(1, std::sync::atomic::Ordering::Relaxed)
|
.fetch_sub(1, std::sync::atomic::Ordering::Relaxed)
|
||||||
== 0
|
== 0
|
||||||
@ -150,7 +150,6 @@ impl Client {
|
|||||||
self.send_message(spam_message.clone()).await
|
self.send_message(spam_message.clone()).await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn send_message(&self, message: String) {
|
pub async fn send_message(&self, message: String) {
|
||||||
let start = SystemTime::now();
|
let start = SystemTime::now();
|
||||||
|
|||||||
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 clap::Parser;
|
||||||
use client::Client;
|
use client::Client;
|
||||||
use tokio::net::TcpStream;
|
use tokio::{net::TcpStream, time::timeout};
|
||||||
|
|
||||||
mod client;
|
mod client;
|
||||||
|
|
||||||
@ -10,11 +10,13 @@ mod client;
|
|||||||
#[command(version, about, long_about = None)]
|
#[command(version, about, long_about = None)]
|
||||||
pub struct Args {
|
pub struct Args {
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
ip: String,
|
pub ip: String,
|
||||||
#[arg(short, long, default_value_t = 1)]
|
#[arg(short, long, default_value_t = 1)]
|
||||||
count: u32,
|
pub count: u32,
|
||||||
#[arg(short, long, default_value_t = 200)]
|
#[arg(short, long, default_value_t = 200)]
|
||||||
delay: u64,
|
pub delay: u64,
|
||||||
|
#[arg(short, long, default_value_t = 5000)]
|
||||||
|
pub timeout: u64,
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
pub spam_message: Option<String>,
|
pub spam_message: Option<String>,
|
||||||
#[arg(long, default_value_t = 210)]
|
#[arg(long, default_value_t = 210)]
|
||||||
@ -35,9 +37,28 @@ async fn main() {
|
|||||||
let mut join_handles = Vec::with_capacity(args.count as usize);
|
let mut join_handles = Vec::with_capacity(args.count as usize);
|
||||||
for i in 0..args.count {
|
for i in 0..args.count {
|
||||||
sleep(Duration::from_millis(args.delay));
|
sleep(Duration::from_millis(args.delay));
|
||||||
let stream = TcpStream::connect(address)
|
let stream_result = timeout(
|
||||||
.await
|
Duration::from_millis(args.timeout),
|
||||||
.expect("Failed to connect to Ip");
|
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 client = Arc::new(Client::new(stream));
|
||||||
let message = Arc::new(args.spam_message.clone());
|
let message = Arc::new(args.spam_message.clone());
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user