fix: of *course* it's FML

This commit is contained in:
Skye 2023-06-05 14:53:01 +09:00
parent 9177e44adb
commit 4bc14d3b3f
Signed by: me
GPG key ID: 0104BC05F41B77B8

View file

@ -73,6 +73,15 @@ impl Handshake {
writer.write_all(&buf).await?; writer.write_all(&buf).await?;
Ok(()) 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)] #[derive(Debug)]
@ -364,9 +373,9 @@ async fn accept_minecraft_connection(mut stream: TcpStream) -> Result<()> {
return Ok(()); return Ok(());
} }
let handshake = Handshake::new(&packet?).await?; 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; 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); drop(map);
let mut handle: ChannelHandle = ChannelHandle::new(&sender, addr).await?; let mut handle: ChannelHandle = ChannelHandle::new(&sender, addr).await?;
let mut buf = vec![]; let mut buf = vec![];