mirror of
https://github.com/timvisee/lazymc.git
synced 2025-05-19 04:40:22 -07:00
Replay client handshake when lobby connects to real server
This commit is contained in:
parent
78a36978f5
commit
e23a61ab0f
4
Cargo.lock
generated
4
Cargo.lock
generated
@ -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",
|
||||
|
@ -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"
|
||||
|
20
src/lobby.rs
20
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(
|
||||
|
@ -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<i32>,
|
||||
/// Handshake as received from client.
|
||||
pub handshake: Option<Handshake>,
|
||||
|
||||
/// Client username.
|
||||
pub username: Option<String>,
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user