feat: server status protocol path implemented
This commit is contained in:
parent
b75eec70e0
commit
b14d3b599d
10 changed files with 544 additions and 79 deletions
28
src/mc_server.rs
Normal file
28
src/mc_server.rs
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
use tokio::net::TcpStream;
|
||||
|
||||
use crate::{
|
||||
packets::{Packet, SendPacket},
|
||||
OpaqueError,
|
||||
};
|
||||
|
||||
#[tracing::instrument(skip(client_stream))]
|
||||
pub async fn handle_ping(client_stream: &mut TcpStream) -> Result<(), OpaqueError> {
|
||||
// --- Respond to ping packet ---
|
||||
let ping_packet = Packet::parse(client_stream)
|
||||
.await
|
||||
.ok_or("Ping packett failed to parse")?;
|
||||
match ping_packet.id.get_int() {
|
||||
1 => Ok(ping_packet
|
||||
.send_packet(client_stream)
|
||||
.await
|
||||
.map_err(|_| "Failed to send ping")?),
|
||||
_ => {
|
||||
return Err(OpaqueError::create(&format!(
|
||||
"Expected ping packet, got: {}",
|
||||
ping_packet.id.get_int()
|
||||
)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// pub async fn handle_redirect(client_stream: &mut TcpStream) -> Result<(), OpaqueError> {}
|
||||
Loading…
Add table
Add a link
Reference in a new issue