From 4bc14d3b3f8e89b2e43722bf2db207cce1898271 Mon Sep 17 00:00:00 2001 From: Skye Date: Mon, 5 Jun 2023 14:53:01 +0900 Subject: [PATCH] fix: of *course* it's FML --- server/src/main.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/server/src/main.rs b/server/src/main.rs index a602f59..a0319dd 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -73,6 +73,15 @@ impl Handshake { writer.write_all(&buf).await?; Ok(()) } + fn normalized_address(&self) -> String { + if let Some(fml2_stripped) = self.server_address.strip_suffix("\0FML2\0") { + fml2_stripped.to_lowercase() + } else if let Some(fml_stripped) = self.server_address.strip_suffix("\0FML\0") { + fml_stripped.to_lowercase() + } else { + self.server_address.to_lowercase() + } + } } #[derive(Debug)] @@ -364,9 +373,9 @@ async fn accept_minecraft_connection(mut stream: TcpStream) -> Result<()> { return Ok(()); } let handshake = Handshake::new(&packet?).await?; - info!("Minecraft client {} is connecting to {}", addr, handshake.server_address); + info!("Minecraft client {} is connecting to {}", addr, handshake.normalized_address()); let map = ROUTING_MAP.read().await; - if let Some(sender) = map.get(&handshake.server_address.to_lowercase()).cloned() { + if let Some(sender) = map.get(&handshake.normalized_address()).cloned() { drop(map); let mut handle: ChannelHandle = ChannelHandle::new(&sender, addr).await?; let mut buf = vec![];