valence/crates/valence_stresser/src/stresser.rs

157 lines
4.5 KiB
Rust
Raw Normal View History

Minimal stresser implementation (#240) <!-- Please make sure that your PR is aligned with the guidelines in CONTRIBUTING.md to the best of your ability. --> <!-- Good PRs have tests! Make sure you have sufficient test coverage. --> ## Description <!-- Describe the changes you've made. You may include any justification you want here. --> An implementation of a Minecraft server stresser for testing purposes. The potential of this pull request is to implement a minimal stresser binary package that would be bound to the local `valence_protocol` package, so it would be always up to date with the latest Valence Minecraft protocol implementation. The MVP version is going to be able concurrently connect headless clients to a target Minecraft server. ## Test Plan <!-- Explain how you tested your changes, and include any code that you used to test this. --> <!-- If there is an example that is sufficient to use in place of a playground, replace the playground section with a note that indicates this. --> <!-- <details> <summary>Playground</summary> ```rust PASTE YOUR PLAYGROUND CODE HERE ``` </details> --> <!-- You need to include steps regardless of whether or not you are using a playground. --> Steps: 1. Ensure that the connection mode is offline 2. Run `cargo run --example bench_players` or any other example 3. Run `cargo run --package valence_stresser -- --target 127.0.0.1:25565 --count 1000` 4. Monitor the `bench_players` output #### Related closes #211 --------- Co-authored-by: Carson McManus <dyc3@users.noreply.github.com>
2023-02-21 15:54:16 +02:00
use std::io::{self, ErrorKind};
use std::net::SocketAddr;
use anyhow::bail;
use tokio::io::AsyncWriteExt;
use tokio::net::TcpStream;
use uuid::Uuid;
use valence_protocol::codec::{PacketDecoder, PacketEncoder};
use valence_protocol::packet::c2s::handshake::handshake::NextState;
use valence_protocol::packet::c2s::handshake::HandshakeC2s;
use valence_protocol::packet::c2s::login::LoginHelloC2s;
use valence_protocol::packet::c2s::play::{
KeepAliveC2s, PositionAndOnGroundC2s, TeleportConfirmC2s,
};
use valence_protocol::packet::{C2sHandshakePacket, S2cLoginPacket, S2cPlayPacket};
use valence_protocol::var_int::VarInt;
use valence_protocol::PROTOCOL_VERSION;
Minimal stresser implementation (#240) <!-- Please make sure that your PR is aligned with the guidelines in CONTRIBUTING.md to the best of your ability. --> <!-- Good PRs have tests! Make sure you have sufficient test coverage. --> ## Description <!-- Describe the changes you've made. You may include any justification you want here. --> An implementation of a Minecraft server stresser for testing purposes. The potential of this pull request is to implement a minimal stresser binary package that would be bound to the local `valence_protocol` package, so it would be always up to date with the latest Valence Minecraft protocol implementation. The MVP version is going to be able concurrently connect headless clients to a target Minecraft server. ## Test Plan <!-- Explain how you tested your changes, and include any code that you used to test this. --> <!-- If there is an example that is sufficient to use in place of a playground, replace the playground section with a note that indicates this. --> <!-- <details> <summary>Playground</summary> ```rust PASTE YOUR PLAYGROUND CODE HERE ``` </details> --> <!-- You need to include steps regardless of whether or not you are using a playground. --> Steps: 1. Ensure that the connection mode is offline 2. Run `cargo run --example bench_players` or any other example 3. Run `cargo run --package valence_stresser -- --target 127.0.0.1:25565 --count 1000` 4. Monitor the `bench_players` output #### Related closes #211 --------- Co-authored-by: Carson McManus <dyc3@users.noreply.github.com>
2023-02-21 15:54:16 +02:00
pub struct SessionParams<'a> {
pub socket_addr: SocketAddr,
pub session_name: &'a str,
pub read_buffer_size: usize,
}
pub async fn make_session<'a>(params: &SessionParams<'a>) -> anyhow::Result<()> {
let sock_addr = params.socket_addr;
let sess_name = params.session_name;
let rb_size = params.read_buffer_size;
let mut conn = match TcpStream::connect(sock_addr).await {
Ok(conn) => {
println!("{sess_name} connected");
conn
}
Err(err) => {
eprintln!("{sess_name} connection failed");
Minimal stresser implementation (#240) <!-- Please make sure that your PR is aligned with the guidelines in CONTRIBUTING.md to the best of your ability. --> <!-- Good PRs have tests! Make sure you have sufficient test coverage. --> ## Description <!-- Describe the changes you've made. You may include any justification you want here. --> An implementation of a Minecraft server stresser for testing purposes. The potential of this pull request is to implement a minimal stresser binary package that would be bound to the local `valence_protocol` package, so it would be always up to date with the latest Valence Minecraft protocol implementation. The MVP version is going to be able concurrently connect headless clients to a target Minecraft server. ## Test Plan <!-- Explain how you tested your changes, and include any code that you used to test this. --> <!-- If there is an example that is sufficient to use in place of a playground, replace the playground section with a note that indicates this. --> <!-- <details> <summary>Playground</summary> ```rust PASTE YOUR PLAYGROUND CODE HERE ``` </details> --> <!-- You need to include steps regardless of whether or not you are using a playground. --> Steps: 1. Ensure that the connection mode is offline 2. Run `cargo run --example bench_players` or any other example 3. Run `cargo run --package valence_stresser -- --target 127.0.0.1:25565 --count 1000` 4. Monitor the `bench_players` output #### Related closes #211 --------- Co-authored-by: Carson McManus <dyc3@users.noreply.github.com>
2023-02-21 15:54:16 +02:00
return Err(err.into());
}
};
conn.set_nodelay(true)?;
Minimal stresser implementation (#240) <!-- Please make sure that your PR is aligned with the guidelines in CONTRIBUTING.md to the best of your ability. --> <!-- Good PRs have tests! Make sure you have sufficient test coverage. --> ## Description <!-- Describe the changes you've made. You may include any justification you want here. --> An implementation of a Minecraft server stresser for testing purposes. The potential of this pull request is to implement a minimal stresser binary package that would be bound to the local `valence_protocol` package, so it would be always up to date with the latest Valence Minecraft protocol implementation. The MVP version is going to be able concurrently connect headless clients to a target Minecraft server. ## Test Plan <!-- Explain how you tested your changes, and include any code that you used to test this. --> <!-- If there is an example that is sufficient to use in place of a playground, replace the playground section with a note that indicates this. --> <!-- <details> <summary>Playground</summary> ```rust PASTE YOUR PLAYGROUND CODE HERE ``` </details> --> <!-- You need to include steps regardless of whether or not you are using a playground. --> Steps: 1. Ensure that the connection mode is offline 2. Run `cargo run --example bench_players` or any other example 3. Run `cargo run --package valence_stresser -- --target 127.0.0.1:25565 --count 1000` 4. Monitor the `bench_players` output #### Related closes #211 --------- Co-authored-by: Carson McManus <dyc3@users.noreply.github.com>
2023-02-21 15:54:16 +02:00
let mut dec = PacketDecoder::new();
let mut enc = PacketEncoder::new();
let server_addr_str = sock_addr.ip().to_string();
Minimal stresser implementation (#240) <!-- Please make sure that your PR is aligned with the guidelines in CONTRIBUTING.md to the best of your ability. --> <!-- Good PRs have tests! Make sure you have sufficient test coverage. --> ## Description <!-- Describe the changes you've made. You may include any justification you want here. --> An implementation of a Minecraft server stresser for testing purposes. The potential of this pull request is to implement a minimal stresser binary package that would be bound to the local `valence_protocol` package, so it would be always up to date with the latest Valence Minecraft protocol implementation. The MVP version is going to be able concurrently connect headless clients to a target Minecraft server. ## Test Plan <!-- Explain how you tested your changes, and include any code that you used to test this. --> <!-- If there is an example that is sufficient to use in place of a playground, replace the playground section with a note that indicates this. --> <!-- <details> <summary>Playground</summary> ```rust PASTE YOUR PLAYGROUND CODE HERE ``` </details> --> <!-- You need to include steps regardless of whether or not you are using a playground. --> Steps: 1. Ensure that the connection mode is offline 2. Run `cargo run --example bench_players` or any other example 3. Run `cargo run --package valence_stresser -- --target 127.0.0.1:25565 --count 1000` 4. Monitor the `bench_players` output #### Related closes #211 --------- Co-authored-by: Carson McManus <dyc3@users.noreply.github.com>
2023-02-21 15:54:16 +02:00
let handshake_pkt = C2sHandshakePacket::HandshakeC2s(HandshakeC2s {
protocol_version: VarInt(PROTOCOL_VERSION),
Minimal stresser implementation (#240) <!-- Please make sure that your PR is aligned with the guidelines in CONTRIBUTING.md to the best of your ability. --> <!-- Good PRs have tests! Make sure you have sufficient test coverage. --> ## Description <!-- Describe the changes you've made. You may include any justification you want here. --> An implementation of a Minecraft server stresser for testing purposes. The potential of this pull request is to implement a minimal stresser binary package that would be bound to the local `valence_protocol` package, so it would be always up to date with the latest Valence Minecraft protocol implementation. The MVP version is going to be able concurrently connect headless clients to a target Minecraft server. ## Test Plan <!-- Explain how you tested your changes, and include any code that you used to test this. --> <!-- If there is an example that is sufficient to use in place of a playground, replace the playground section with a note that indicates this. --> <!-- <details> <summary>Playground</summary> ```rust PASTE YOUR PLAYGROUND CODE HERE ``` </details> --> <!-- You need to include steps regardless of whether or not you are using a playground. --> Steps: 1. Ensure that the connection mode is offline 2. Run `cargo run --example bench_players` or any other example 3. Run `cargo run --package valence_stresser -- --target 127.0.0.1:25565 --count 1000` 4. Monitor the `bench_players` output #### Related closes #211 --------- Co-authored-by: Carson McManus <dyc3@users.noreply.github.com>
2023-02-21 15:54:16 +02:00
server_address: &server_addr_str,
server_port: sock_addr.port(),
next_state: NextState::Login,
Minimal stresser implementation (#240) <!-- Please make sure that your PR is aligned with the guidelines in CONTRIBUTING.md to the best of your ability. --> <!-- Good PRs have tests! Make sure you have sufficient test coverage. --> ## Description <!-- Describe the changes you've made. You may include any justification you want here. --> An implementation of a Minecraft server stresser for testing purposes. The potential of this pull request is to implement a minimal stresser binary package that would be bound to the local `valence_protocol` package, so it would be always up to date with the latest Valence Minecraft protocol implementation. The MVP version is going to be able concurrently connect headless clients to a target Minecraft server. ## Test Plan <!-- Explain how you tested your changes, and include any code that you used to test this. --> <!-- If there is an example that is sufficient to use in place of a playground, replace the playground section with a note that indicates this. --> <!-- <details> <summary>Playground</summary> ```rust PASTE YOUR PLAYGROUND CODE HERE ``` </details> --> <!-- You need to include steps regardless of whether or not you are using a playground. --> Steps: 1. Ensure that the connection mode is offline 2. Run `cargo run --example bench_players` or any other example 3. Run `cargo run --package valence_stresser -- --target 127.0.0.1:25565 --count 1000` 4. Monitor the `bench_players` output #### Related closes #211 --------- Co-authored-by: Carson McManus <dyc3@users.noreply.github.com>
2023-02-21 15:54:16 +02:00
});
enc.append_packet(&handshake_pkt)?;
Minimal stresser implementation (#240) <!-- Please make sure that your PR is aligned with the guidelines in CONTRIBUTING.md to the best of your ability. --> <!-- Good PRs have tests! Make sure you have sufficient test coverage. --> ## Description <!-- Describe the changes you've made. You may include any justification you want here. --> An implementation of a Minecraft server stresser for testing purposes. The potential of this pull request is to implement a minimal stresser binary package that would be bound to the local `valence_protocol` package, so it would be always up to date with the latest Valence Minecraft protocol implementation. The MVP version is going to be able concurrently connect headless clients to a target Minecraft server. ## Test Plan <!-- Explain how you tested your changes, and include any code that you used to test this. --> <!-- If there is an example that is sufficient to use in place of a playground, replace the playground section with a note that indicates this. --> <!-- <details> <summary>Playground</summary> ```rust PASTE YOUR PLAYGROUND CODE HERE ``` </details> --> <!-- You need to include steps regardless of whether or not you are using a playground. --> Steps: 1. Ensure that the connection mode is offline 2. Run `cargo run --example bench_players` or any other example 3. Run `cargo run --package valence_stresser -- --target 127.0.0.1:25565 --count 1000` 4. Monitor the `bench_players` output #### Related closes #211 --------- Co-authored-by: Carson McManus <dyc3@users.noreply.github.com>
2023-02-21 15:54:16 +02:00
enc.append_packet(&LoginHelloC2s {
username: sess_name,
Minimal stresser implementation (#240) <!-- Please make sure that your PR is aligned with the guidelines in CONTRIBUTING.md to the best of your ability. --> <!-- Good PRs have tests! Make sure you have sufficient test coverage. --> ## Description <!-- Describe the changes you've made. You may include any justification you want here. --> An implementation of a Minecraft server stresser for testing purposes. The potential of this pull request is to implement a minimal stresser binary package that would be bound to the local `valence_protocol` package, so it would be always up to date with the latest Valence Minecraft protocol implementation. The MVP version is going to be able concurrently connect headless clients to a target Minecraft server. ## Test Plan <!-- Explain how you tested your changes, and include any code that you used to test this. --> <!-- If there is an example that is sufficient to use in place of a playground, replace the playground section with a note that indicates this. --> <!-- <details> <summary>Playground</summary> ```rust PASTE YOUR PLAYGROUND CODE HERE ``` </details> --> <!-- You need to include steps regardless of whether or not you are using a playground. --> Steps: 1. Ensure that the connection mode is offline 2. Run `cargo run --example bench_players` or any other example 3. Run `cargo run --package valence_stresser -- --target 127.0.0.1:25565 --count 1000` 4. Monitor the `bench_players` output #### Related closes #211 --------- Co-authored-by: Carson McManus <dyc3@users.noreply.github.com>
2023-02-21 15:54:16 +02:00
profile_id: Some(Uuid::new_v4()),
})?;
Minimal stresser implementation (#240) <!-- Please make sure that your PR is aligned with the guidelines in CONTRIBUTING.md to the best of your ability. --> <!-- Good PRs have tests! Make sure you have sufficient test coverage. --> ## Description <!-- Describe the changes you've made. You may include any justification you want here. --> An implementation of a Minecraft server stresser for testing purposes. The potential of this pull request is to implement a minimal stresser binary package that would be bound to the local `valence_protocol` package, so it would be always up to date with the latest Valence Minecraft protocol implementation. The MVP version is going to be able concurrently connect headless clients to a target Minecraft server. ## Test Plan <!-- Explain how you tested your changes, and include any code that you used to test this. --> <!-- If there is an example that is sufficient to use in place of a playground, replace the playground section with a note that indicates this. --> <!-- <details> <summary>Playground</summary> ```rust PASTE YOUR PLAYGROUND CODE HERE ``` </details> --> <!-- You need to include steps regardless of whether or not you are using a playground. --> Steps: 1. Ensure that the connection mode is offline 2. Run `cargo run --example bench_players` or any other example 3. Run `cargo run --package valence_stresser -- --target 127.0.0.1:25565 --count 1000` 4. Monitor the `bench_players` output #### Related closes #211 --------- Co-authored-by: Carson McManus <dyc3@users.noreply.github.com>
2023-02-21 15:54:16 +02:00
let write_buf = enc.take();
conn.write_all(&write_buf).await?;
loop {
dec.reserve(rb_size);
let mut read_buf = dec.take_capacity();
conn.readable().await?;
match conn.try_read_buf(&mut read_buf) {
Ok(0) => return Err(io::Error::from(ErrorKind::UnexpectedEof).into()),
Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => continue,
Err(e) => return Err(e.into()),
Ok(_) => (),
};
dec.queue_bytes(read_buf);
if let Ok(Some(pkt)) = dec.try_next_packet::<S2cLoginPacket>() {
match pkt {
S2cLoginPacket::LoginCompressionS2c(p) => {
Minimal stresser implementation (#240) <!-- Please make sure that your PR is aligned with the guidelines in CONTRIBUTING.md to the best of your ability. --> <!-- Good PRs have tests! Make sure you have sufficient test coverage. --> ## Description <!-- Describe the changes you've made. You may include any justification you want here. --> An implementation of a Minecraft server stresser for testing purposes. The potential of this pull request is to implement a minimal stresser binary package that would be bound to the local `valence_protocol` package, so it would be always up to date with the latest Valence Minecraft protocol implementation. The MVP version is going to be able concurrently connect headless clients to a target Minecraft server. ## Test Plan <!-- Explain how you tested your changes, and include any code that you used to test this. --> <!-- If there is an example that is sufficient to use in place of a playground, replace the playground section with a note that indicates this. --> <!-- <details> <summary>Playground</summary> ```rust PASTE YOUR PLAYGROUND CODE HERE ``` </details> --> <!-- You need to include steps regardless of whether or not you are using a playground. --> Steps: 1. Ensure that the connection mode is offline 2. Run `cargo run --example bench_players` or any other example 3. Run `cargo run --package valence_stresser -- --target 127.0.0.1:25565 --count 1000` 4. Monitor the `bench_players` output #### Related closes #211 --------- Co-authored-by: Carson McManus <dyc3@users.noreply.github.com>
2023-02-21 15:54:16 +02:00
let threshold = p.threshold.0 as u32;
dec.set_compression(true);
enc.set_compression(Some(threshold));
}
S2cLoginPacket::LoginSuccessS2c(_) => {
Minimal stresser implementation (#240) <!-- Please make sure that your PR is aligned with the guidelines in CONTRIBUTING.md to the best of your ability. --> <!-- Good PRs have tests! Make sure you have sufficient test coverage. --> ## Description <!-- Describe the changes you've made. You may include any justification you want here. --> An implementation of a Minecraft server stresser for testing purposes. The potential of this pull request is to implement a minimal stresser binary package that would be bound to the local `valence_protocol` package, so it would be always up to date with the latest Valence Minecraft protocol implementation. The MVP version is going to be able concurrently connect headless clients to a target Minecraft server. ## Test Plan <!-- Explain how you tested your changes, and include any code that you used to test this. --> <!-- If there is an example that is sufficient to use in place of a playground, replace the playground section with a note that indicates this. --> <!-- <details> <summary>Playground</summary> ```rust PASTE YOUR PLAYGROUND CODE HERE ``` </details> --> <!-- You need to include steps regardless of whether or not you are using a playground. --> Steps: 1. Ensure that the connection mode is offline 2. Run `cargo run --example bench_players` or any other example 3. Run `cargo run --package valence_stresser -- --target 127.0.0.1:25565 --count 1000` 4. Monitor the `bench_players` output #### Related closes #211 --------- Co-authored-by: Carson McManus <dyc3@users.noreply.github.com>
2023-02-21 15:54:16 +02:00
break;
}
S2cLoginPacket::LoginHelloS2c(_) => {
Minimal stresser implementation (#240) <!-- Please make sure that your PR is aligned with the guidelines in CONTRIBUTING.md to the best of your ability. --> <!-- Good PRs have tests! Make sure you have sufficient test coverage. --> ## Description <!-- Describe the changes you've made. You may include any justification you want here. --> An implementation of a Minecraft server stresser for testing purposes. The potential of this pull request is to implement a minimal stresser binary package that would be bound to the local `valence_protocol` package, so it would be always up to date with the latest Valence Minecraft protocol implementation. The MVP version is going to be able concurrently connect headless clients to a target Minecraft server. ## Test Plan <!-- Explain how you tested your changes, and include any code that you used to test this. --> <!-- If there is an example that is sufficient to use in place of a playground, replace the playground section with a note that indicates this. --> <!-- <details> <summary>Playground</summary> ```rust PASTE YOUR PLAYGROUND CODE HERE ``` </details> --> <!-- You need to include steps regardless of whether or not you are using a playground. --> Steps: 1. Ensure that the connection mode is offline 2. Run `cargo run --example bench_players` or any other example 3. Run `cargo run --package valence_stresser -- --target 127.0.0.1:25565 --count 1000` 4. Monitor the `bench_players` output #### Related closes #211 --------- Co-authored-by: Carson McManus <dyc3@users.noreply.github.com>
2023-02-21 15:54:16 +02:00
bail!("encryption not implemented");
}
_ => (),
}
}
}
println!("{sess_name} logined");
loop {
while !dec.has_next_packet()? {
dec.reserve(rb_size);
let mut read_buf = dec.take_capacity();
conn.readable().await?;
match conn.try_read_buf(&mut read_buf) {
Ok(0) => return Err(io::Error::from(ErrorKind::UnexpectedEof).into()),
Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => continue,
Err(e) => return Err(e.into()),
Ok(_) => (),
};
dec.queue_bytes(read_buf);
}
match dec.try_next_packet::<S2cPlayPacket>() {
Ok(None) => continue,
Ok(Some(pkt)) => match pkt {
S2cPlayPacket::KeepAliveS2c(p) => {
enc.clear();
enc.append_packet(&KeepAliveC2s { id: p.id })?;
Minimal stresser implementation (#240) <!-- Please make sure that your PR is aligned with the guidelines in CONTRIBUTING.md to the best of your ability. --> <!-- Good PRs have tests! Make sure you have sufficient test coverage. --> ## Description <!-- Describe the changes you've made. You may include any justification you want here. --> An implementation of a Minecraft server stresser for testing purposes. The potential of this pull request is to implement a minimal stresser binary package that would be bound to the local `valence_protocol` package, so it would be always up to date with the latest Valence Minecraft protocol implementation. The MVP version is going to be able concurrently connect headless clients to a target Minecraft server. ## Test Plan <!-- Explain how you tested your changes, and include any code that you used to test this. --> <!-- If there is an example that is sufficient to use in place of a playground, replace the playground section with a note that indicates this. --> <!-- <details> <summary>Playground</summary> ```rust PASTE YOUR PLAYGROUND CODE HERE ``` </details> --> <!-- You need to include steps regardless of whether or not you are using a playground. --> Steps: 1. Ensure that the connection mode is offline 2. Run `cargo run --example bench_players` or any other example 3. Run `cargo run --package valence_stresser -- --target 127.0.0.1:25565 --count 1000` 4. Monitor the `bench_players` output #### Related closes #211 --------- Co-authored-by: Carson McManus <dyc3@users.noreply.github.com>
2023-02-21 15:54:16 +02:00
conn.write_all(&enc.take()).await?;
println!("{sess_name} keep alive")
}
S2cPlayPacket::PlayerPositionLookS2c(p) => {
Minimal stresser implementation (#240) <!-- Please make sure that your PR is aligned with the guidelines in CONTRIBUTING.md to the best of your ability. --> <!-- Good PRs have tests! Make sure you have sufficient test coverage. --> ## Description <!-- Describe the changes you've made. You may include any justification you want here. --> An implementation of a Minecraft server stresser for testing purposes. The potential of this pull request is to implement a minimal stresser binary package that would be bound to the local `valence_protocol` package, so it would be always up to date with the latest Valence Minecraft protocol implementation. The MVP version is going to be able concurrently connect headless clients to a target Minecraft server. ## Test Plan <!-- Explain how you tested your changes, and include any code that you used to test this. --> <!-- If there is an example that is sufficient to use in place of a playground, replace the playground section with a note that indicates this. --> <!-- <details> <summary>Playground</summary> ```rust PASTE YOUR PLAYGROUND CODE HERE ``` </details> --> <!-- You need to include steps regardless of whether or not you are using a playground. --> Steps: 1. Ensure that the connection mode is offline 2. Run `cargo run --example bench_players` or any other example 3. Run `cargo run --package valence_stresser -- --target 127.0.0.1:25565 --count 1000` 4. Monitor the `bench_players` output #### Related closes #211 --------- Co-authored-by: Carson McManus <dyc3@users.noreply.github.com>
2023-02-21 15:54:16 +02:00
enc.clear();
enc.append_packet(&TeleportConfirmC2s {
Minimal stresser implementation (#240) <!-- Please make sure that your PR is aligned with the guidelines in CONTRIBUTING.md to the best of your ability. --> <!-- Good PRs have tests! Make sure you have sufficient test coverage. --> ## Description <!-- Describe the changes you've made. You may include any justification you want here. --> An implementation of a Minecraft server stresser for testing purposes. The potential of this pull request is to implement a minimal stresser binary package that would be bound to the local `valence_protocol` package, so it would be always up to date with the latest Valence Minecraft protocol implementation. The MVP version is going to be able concurrently connect headless clients to a target Minecraft server. ## Test Plan <!-- Explain how you tested your changes, and include any code that you used to test this. --> <!-- If there is an example that is sufficient to use in place of a playground, replace the playground section with a note that indicates this. --> <!-- <details> <summary>Playground</summary> ```rust PASTE YOUR PLAYGROUND CODE HERE ``` </details> --> <!-- You need to include steps regardless of whether or not you are using a playground. --> Steps: 1. Ensure that the connection mode is offline 2. Run `cargo run --example bench_players` or any other example 3. Run `cargo run --package valence_stresser -- --target 127.0.0.1:25565 --count 1000` 4. Monitor the `bench_players` output #### Related closes #211 --------- Co-authored-by: Carson McManus <dyc3@users.noreply.github.com>
2023-02-21 15:54:16 +02:00
teleport_id: p.teleport_id,
})?;
Minimal stresser implementation (#240) <!-- Please make sure that your PR is aligned with the guidelines in CONTRIBUTING.md to the best of your ability. --> <!-- Good PRs have tests! Make sure you have sufficient test coverage. --> ## Description <!-- Describe the changes you've made. You may include any justification you want here. --> An implementation of a Minecraft server stresser for testing purposes. The potential of this pull request is to implement a minimal stresser binary package that would be bound to the local `valence_protocol` package, so it would be always up to date with the latest Valence Minecraft protocol implementation. The MVP version is going to be able concurrently connect headless clients to a target Minecraft server. ## Test Plan <!-- Explain how you tested your changes, and include any code that you used to test this. --> <!-- If there is an example that is sufficient to use in place of a playground, replace the playground section with a note that indicates this. --> <!-- <details> <summary>Playground</summary> ```rust PASTE YOUR PLAYGROUND CODE HERE ``` </details> --> <!-- You need to include steps regardless of whether or not you are using a playground. --> Steps: 1. Ensure that the connection mode is offline 2. Run `cargo run --example bench_players` or any other example 3. Run `cargo run --package valence_stresser -- --target 127.0.0.1:25565 --count 1000` 4. Monitor the `bench_players` output #### Related closes #211 --------- Co-authored-by: Carson McManus <dyc3@users.noreply.github.com>
2023-02-21 15:54:16 +02:00
enc.append_packet(&PositionAndOnGroundC2s {
Minimal stresser implementation (#240) <!-- Please make sure that your PR is aligned with the guidelines in CONTRIBUTING.md to the best of your ability. --> <!-- Good PRs have tests! Make sure you have sufficient test coverage. --> ## Description <!-- Describe the changes you've made. You may include any justification you want here. --> An implementation of a Minecraft server stresser for testing purposes. The potential of this pull request is to implement a minimal stresser binary package that would be bound to the local `valence_protocol` package, so it would be always up to date with the latest Valence Minecraft protocol implementation. The MVP version is going to be able concurrently connect headless clients to a target Minecraft server. ## Test Plan <!-- Explain how you tested your changes, and include any code that you used to test this. --> <!-- If there is an example that is sufficient to use in place of a playground, replace the playground section with a note that indicates this. --> <!-- <details> <summary>Playground</summary> ```rust PASTE YOUR PLAYGROUND CODE HERE ``` </details> --> <!-- You need to include steps regardless of whether or not you are using a playground. --> Steps: 1. Ensure that the connection mode is offline 2. Run `cargo run --example bench_players` or any other example 3. Run `cargo run --package valence_stresser -- --target 127.0.0.1:25565 --count 1000` 4. Monitor the `bench_players` output #### Related closes #211 --------- Co-authored-by: Carson McManus <dyc3@users.noreply.github.com>
2023-02-21 15:54:16 +02:00
position: p.position,
on_ground: true,
})?;
Minimal stresser implementation (#240) <!-- Please make sure that your PR is aligned with the guidelines in CONTRIBUTING.md to the best of your ability. --> <!-- Good PRs have tests! Make sure you have sufficient test coverage. --> ## Description <!-- Describe the changes you've made. You may include any justification you want here. --> An implementation of a Minecraft server stresser for testing purposes. The potential of this pull request is to implement a minimal stresser binary package that would be bound to the local `valence_protocol` package, so it would be always up to date with the latest Valence Minecraft protocol implementation. The MVP version is going to be able concurrently connect headless clients to a target Minecraft server. ## Test Plan <!-- Explain how you tested your changes, and include any code that you used to test this. --> <!-- If there is an example that is sufficient to use in place of a playground, replace the playground section with a note that indicates this. --> <!-- <details> <summary>Playground</summary> ```rust PASTE YOUR PLAYGROUND CODE HERE ``` </details> --> <!-- You need to include steps regardless of whether or not you are using a playground. --> Steps: 1. Ensure that the connection mode is offline 2. Run `cargo run --example bench_players` or any other example 3. Run `cargo run --package valence_stresser -- --target 127.0.0.1:25565 --count 1000` 4. Monitor the `bench_players` output #### Related closes #211 --------- Co-authored-by: Carson McManus <dyc3@users.noreply.github.com>
2023-02-21 15:54:16 +02:00
conn.write_all(&enc.take()).await?;
println!("{sess_name} spawned")
}
_ => (),
},
Err(err) => return Err(err),
}
}
}