-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
af9119e
commit bdadc20
Showing
15 changed files
with
104 additions
and
79 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use tokio::net::{TcpStream, ToSocketAddrs}; | ||
use uuid::Uuid; | ||
|
||
mod handshake; | ||
|
||
pub struct Bot { | ||
name: String, | ||
uuid: Uuid, | ||
buf: Vec<u8>, | ||
connection: TcpStream, | ||
} | ||
|
||
impl Bot { | ||
pub async fn new(name: String, uuid: Uuid, addr: impl ToSocketAddrs) -> Self { | ||
let addr = TcpStream::connect(addr).await.unwrap(); | ||
|
||
Self { | ||
name, | ||
uuid, | ||
buf: Vec::new(), | ||
connection: addr, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
use antithesis::random::AntithesisRng; | ||
use rand::Rng; | ||
use tokio::io::AsyncWriteExt; | ||
use valence_protocol::{ | ||
Bounded, Encode, PROTOCOL_VERSION, VarInt, packets, | ||
packets::handshaking::handshake_c2s::HandshakeNextState, | ||
}; | ||
|
||
use crate::{bot::Bot, util::random_either}; | ||
|
||
impl Bot { | ||
pub async fn handshake(mut self) -> eyre::Result<()> { | ||
let mut rng = AntithesisRng; | ||
|
||
let protocol_version: i32 = random_either(|| PROTOCOL_VERSION, || rng.r#gen::<i32>()); | ||
|
||
let is_correct_protocol_version = protocol_version == PROTOCOL_VERSION; | ||
|
||
let addr = "placeholder"; | ||
|
||
let packet = packets::handshaking::HandshakeC2s { | ||
protocol_version: VarInt(protocol_version), | ||
server_address: Bounded(addr), | ||
server_port: 25565, // probably does not matter | ||
next_state: HandshakeNextState::Status, | ||
}; | ||
|
||
packet | ||
.encode(&mut self.buf) | ||
.map_err(|e| eyre::eyre!("failed to encode handshake packet: {e}"))?; | ||
|
||
self.connection.write_all(&self.buf).await?; | ||
|
||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
use eyre::{eyre, Context}; | ||
use eyre::Context; | ||
use hyperion_bot::bootstrap; | ||
|
||
#[tokio::main] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.