diff options
Diffstat (limited to 'minecraft-client/src')
| -rw-r--r-- | minecraft-client/src/connect.rs | 53 | ||||
| -rw-r--r-- | minecraft-client/src/crypt.rs | 0 | ||||
| -rw-r--r-- | minecraft-client/src/lib.rs | 13 | ||||
| -rw-r--r-- | minecraft-client/src/ping.rs | 44 |
4 files changed, 0 insertions, 110 deletions
diff --git a/minecraft-client/src/connect.rs b/minecraft-client/src/connect.rs deleted file mode 100644 index 5eedbf96..00000000 --- a/minecraft-client/src/connect.rs +++ /dev/null @@ -1,53 +0,0 @@ -///! Connect to Minecraft servers. -use minecraft_protocol::{ - connect::HandshakeConnection, - packets::{ - handshake::client_intention_packet::ClientIntentionPacket, - login::{serverbound_hello_packet::ServerboundHelloPacket, LoginPacket}, - ConnectionProtocol, PROTOCOL_VERSION, - }, - resolver, ServerAddress, -}; - -pub async fn join_server(address: &ServerAddress) -> Result<(), String> { - let username = "bot".to_string(); - - let resolved_address = resolver::resolve_address(address).await?; - - let mut conn = HandshakeConnection::new(&resolved_address).await?; - - // handshake - conn.write( - ClientIntentionPacket { - protocol_version: PROTOCOL_VERSION, - hostname: address.host.clone(), - port: address.port, - intention: ConnectionProtocol::Login, - } - .get(), - ) - .await; - let mut conn = conn.login(); - - // login start - conn.write(ServerboundHelloPacket { username }.get()).await; - - // encryption request - loop { - match conn.read().await.unwrap() { - LoginPacket::ClientboundHelloPacket(encryption_request_packet) => { - println!( - "Got encryption request {:?} {:?}", - encryption_request_packet.nonce, encryption_request_packet.public_key - ); - } - _ => (), - } - } - - // TODO: client auth - - // TODO: encryption response - - Ok(()) -} diff --git a/minecraft-client/src/crypt.rs b/minecraft-client/src/crypt.rs deleted file mode 100644 index e69de29b..00000000 --- a/minecraft-client/src/crypt.rs +++ /dev/null diff --git a/minecraft-client/src/lib.rs b/minecraft-client/src/lib.rs deleted file mode 100644 index d4ceebde..00000000 --- a/minecraft-client/src/lib.rs +++ /dev/null @@ -1,13 +0,0 @@ -//! Significantly abstract minecraft-protocol so it's actually useable for bots. - -pub mod connect; -pub mod ping; - -#[cfg(test)] -mod tests { - #[test] - fn it_works() { - let result = 2 + 2; - assert_eq!(result, 4); - } -} diff --git a/minecraft-client/src/ping.rs b/minecraft-client/src/ping.rs deleted file mode 100644 index ff869d4e..00000000 --- a/minecraft-client/src/ping.rs +++ /dev/null @@ -1,44 +0,0 @@ -///! Ping Minecraft servers. -use minecraft_protocol::{ - connect::HandshakeConnection, - packets::{ - handshake::client_intention_packet::ClientIntentionPacket, - status::{ - clientbound_status_response_packet::ClientboundStatusResponsePacket, - serverbound_status_request_packet::ServerboundStatusRequestPacket, StatusPacket, - }, - ConnectionProtocol, PROTOCOL_VERSION, - }, - resolver, ServerAddress, -}; - -pub async fn ping_server( - address: &ServerAddress, -) -> Result<ClientboundStatusResponsePacket, String> { - let resolved_address = resolver::resolve_address(address).await?; - - let mut conn = HandshakeConnection::new(&resolved_address).await?; - - // send the client intention packet and switch to the status state - conn.write( - ClientIntentionPacket { - protocol_version: PROTOCOL_VERSION, - hostname: address.host.clone(), - port: address.port, - intention: ConnectionProtocol::Status, - } - .get(), - ) - .await; - let mut conn = conn.status(); - - // send the empty status request packet - conn.write(ServerboundStatusRequestPacket {}.get()).await; - - let packet = conn.read().await.unwrap(); - - match packet { - StatusPacket::ClientboundStatusResponsePacket(p) => Ok(*p), - _ => Err("Invalid packet type".to_string()), - } -} |
