From f6e874c4174205a48c627e75515dcf978356287d Mon Sep 17 00:00:00 2001 From: Iaiao Date: Sun, 5 Dec 2021 16:13:01 +0200 Subject: [PATCH 1/4] Kick the player if the server is outdated --- feather/server/src/initial_handler.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/feather/server/src/initial_handler.rs b/feather/server/src/initial_handler.rs index 4266d5884..211660c8d 100644 --- a/feather/server/src/initial_handler.rs +++ b/feather/server/src/initial_handler.rs @@ -27,6 +27,7 @@ use uuid::Uuid; use self::proxy::ProxyData; +const VERSION_STRING: &str = "1.16.5"; const SERVER_NAME: &str = "Feather 1.16.5"; const PROTOCOL_VERSION: i32 = 754; @@ -63,11 +64,11 @@ pub async fn handle(worker: &mut Worker) -> anyhow::Result { match handshake.next_state { HandshakeState::Status => handle_status(worker).await, HandshakeState::Login => { - if handshake.protocol_version < PROTOCOL_VERSION { + if handshake.protocol_version != PROTOCOL_VERSION { worker .write(ServerLoginPacket::DisconnectLogin(DisconnectLogin { reason: Text::from( - "Invalid protocol! The server is running on version 1.16!", + "Invalid protocol! The server is running on version {}!", VERSION_STRING ) .to_string(), })) From b65adee660da581e1bc9b5660224485e787bfda0 Mon Sep 17 00:00:00 2001 From: Iaiao Date: Sun, 5 Dec 2021 16:16:48 +0200 Subject: [PATCH 2/4] Run cargo fmt --- feather/server/src/initial_handler.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/feather/server/src/initial_handler.rs b/feather/server/src/initial_handler.rs index 211660c8d..c3e960ee8 100644 --- a/feather/server/src/initial_handler.rs +++ b/feather/server/src/initial_handler.rs @@ -68,7 +68,8 @@ pub async fn handle(worker: &mut Worker) -> anyhow::Result { worker .write(ServerLoginPacket::DisconnectLogin(DisconnectLogin { reason: Text::from( - "Invalid protocol! The server is running on version {}!", VERSION_STRING + "Invalid protocol! The server is running on version {}!", + VERSION_STRING, ) .to_string(), })) From 6afe350f07c98fdb9f32133b55182a5b2364c634 Mon Sep 17 00:00:00 2001 From: Iaiao Date: Thu, 6 Jan 2022 15:15:19 +0200 Subject: [PATCH 3/4] Change InitialHandling::Disconnect documentation --- feather/server/src/initial_handler.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/feather/server/src/initial_handler.rs b/feather/server/src/initial_handler.rs index c3e960ee8..c2e5ecb99 100644 --- a/feather/server/src/initial_handler.rs +++ b/feather/server/src/initial_handler.rs @@ -46,8 +46,7 @@ pub struct NewPlayer { /// Result of initial handling. pub enum InitialHandling { - /// The client should be disconnected (sent when - /// the connection was just a "status" ping.) + /// The client should be disconnected. Disconnect, /// We should create a new player. Join(NewPlayer), From 58d2938d18391b49ea0cc21bf18088dcbf6b1518 Mon Sep 17 00:00:00 2001 From: Iaiao Date: Thu, 6 Jan 2022 16:36:29 +0200 Subject: [PATCH 4/4] Fix --- feather/server/src/initial_handler.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/feather/server/src/initial_handler.rs b/feather/server/src/initial_handler.rs index c2e5ecb99..6a4d16b9c 100644 --- a/feather/server/src/initial_handler.rs +++ b/feather/server/src/initial_handler.rs @@ -66,10 +66,10 @@ pub async fn handle(worker: &mut Worker) -> anyhow::Result { if handshake.protocol_version != PROTOCOL_VERSION { worker .write(ServerLoginPacket::DisconnectLogin(DisconnectLogin { - reason: Text::from( + reason: Text::from(format!( "Invalid protocol! The server is running on version {}!", VERSION_STRING, - ) + )) .to_string(), })) .await