diff --git a/Cargo.lock b/Cargo.lock index a1ef194..27d3e42 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -869,7 +869,7 @@ checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" [[package]] name = "minecraft-protocol" version = "0.1.0" -source = "git+https://github.com/timvisee/rust-minecraft-protocol?rev=356ea54#356ea5424374c5a7249be2f0f13fd3e0e2db5b58" +source = "git+https://github.com/timvisee/rust-minecraft-protocol?rev=6d1ef0b#6d1ef0b27d7d49ee25109256e2c6b7a095ef255d" dependencies = [ "byteorder", "minecraft-protocol-derive", @@ -882,7 +882,7 @@ dependencies = [ [[package]] name = "minecraft-protocol-derive" version = "0.0.0" -source = "git+https://github.com/timvisee/rust-minecraft-protocol?rev=356ea54#356ea5424374c5a7249be2f0f13fd3e0e2db5b58" +source = "git+https://github.com/timvisee/rust-minecraft-protocol?rev=6d1ef0b#6d1ef0b27d7d49ee25109256e2c6b7a095ef255d" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 98e91ea..9ff52cb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -42,7 +42,7 @@ dotenv = "0.15" flate2 = { version = "1.0", default-features = false, features = ["default"] } futures = { version = "0.3", default-features = false, features = ["executor"] } log = "0.4" -minecraft-protocol = { git = "https://github.com/timvisee/rust-minecraft-protocol", rev = "356ea54" } +minecraft-protocol = { git = "https://github.com/timvisee/rust-minecraft-protocol", rev = "6d1ef0b" } notify = "4.0" pretty_env_logger = "0.4" proxy-protocol = "0.5" diff --git a/src/lobby.rs b/src/lobby.rs index 448b56d..89499f3 100644 --- a/src/lobby.rs +++ b/src/lobby.rs @@ -8,7 +8,6 @@ use bytes::BytesMut; use futures::FutureExt; use minecraft_protocol::data::chat::{Message, Payload}; use minecraft_protocol::decoder::Decoder; -use minecraft_protocol::version::v1_14_4::handshake::Handshake; use minecraft_protocol::version::v1_14_4::login::{LoginStart, LoginSuccess, SetCompression}; use minecraft_protocol::version::v1_17_1::game::{ ClientBoundKeepAlive, ClientBoundPluginMessage, JoinGame, NamedSoundEffect, @@ -608,18 +607,13 @@ async fn connect_to_server_no_timeout( let (mut reader, mut writer) = outbound.split(); - // Handshake packet - packet::write_packet( - Handshake { - protocol_version: client_info.protocol_version.unwrap(), - server_addr: config.server.address.ip().to_string(), - server_port: config.server.address.port(), - next_state: ClientState::Login.to_id(), - }, - &tmp_client, - &mut writer, - ) - .await?; + // Replay client handshake packet + assert_eq!( + client_info.handshake.as_ref().unwrap().next_state, + ClientState::Login.to_id(), + "Client handshake should have login as next state" + ); + packet::write_packet(client_info.handshake.unwrap(), &tmp_client, &mut writer).await?; // Request login start packet::write_packet( diff --git a/src/proto/client.rs b/src/proto/client.rs index 4d82eb2..82762ab 100644 --- a/src/proto/client.rs +++ b/src/proto/client.rs @@ -2,6 +2,8 @@ use std::net::SocketAddr; use std::sync::atomic::{AtomicI32, Ordering}; use std::sync::Mutex; +use minecraft_protocol::version::v1_14_4::handshake::Handshake; + /// Client state. /// /// Note: this does not keep track of encryption states. @@ -113,8 +115,8 @@ impl Default for ClientState { /// Client info, useful during connection handling. #[derive(Debug, Clone, Default)] pub struct ClientInfo { - /// Client protocol version. - pub protocol_version: Option, + /// Handshake as received from client. + pub handshake: Option, /// Client username. pub username: Option, diff --git a/src/status.rs b/src/status.rs index ed96be5..c6fbad9 100644 --- a/src/status.rs +++ b/src/status.rs @@ -84,9 +84,7 @@ pub async fn serve( }; // Update client info and client state - client_info - .protocol_version - .replace(handshake.protocol_version); + client_info.handshake.replace(handshake); client.set_state(new_state); // If loggin in with handshake, remember inbound