fix: properly read Status Request

This commit is contained in:
Skye 2024-02-06 15:34:06 +09:00
parent fa99261efc
commit 5d36e5a9ba
Signed by: me
GPG key ID: 0104BC05F41B77B8

View file

@ -273,6 +273,12 @@ async fn politely_disconnect(
) -> anyhow::Result<()> {
match handshake.next_state {
netty::HandshakeType::Status => {
let packet = netty::read_packet(&mut connection).await?;
let mut packet = packet.as_slice();
let id = packet.read_varint()?;
if id != 0 {
return Err(anyhow!("Packet isn't a Status Request(0x00), but {:#04x}", id));
}
let mut buf = vec![];
buf.write_varint(0).await?;
buf.write_string(include_str!("./serverlistping_response.json"))