From bebca902df90b9107b97cad4b7f715a77e9333bd Mon Sep 17 00:00:00 2001 From: Tamipes Date: Thu, 29 Jan 2026 10:22:58 +0100 Subject: [PATCH 1/2] feat: call `start_watcher` when connecting to an already running instance (used to be only when starting the server) --- src/main.rs | 3 +++ src/mc_server.rs | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/src/main.rs b/src/main.rs index 2d2ab5d..f4f7e31 100644 --- a/src/main.rs +++ b/src/main.rs @@ -240,6 +240,9 @@ async fn handle_login( tracing::debug!(msg = "server status", status = ?status); match status { ServerDeploymentStatus::Connectable(mut server_stream) => { + api.start_watch(server.clone(), Duration::from_secs(600)) + .await?; + // referenced from: // https://github.com/hanyu-dev/tokio-splice2/blob/fc47199fffde8946b0acf867d1fa0b2222267a34/examples/proxy.rs let io_sl2sr = tokio_splice2::context::SpliceIoCtx::prepare() diff --git a/src/mc_server.rs b/src/mc_server.rs index 2d1525c..069e27a 100644 --- a/src/mc_server.rs +++ b/src/mc_server.rs @@ -123,6 +123,10 @@ pub trait MinecraftServerHandle: Clone { pub trait MinecraftAPI { async fn query_server(&self, addr: &str, port: &str) -> Result; + + // TODO: move the implementation to here, but + /// This should be callable even if there is already a watcher, + /// and it should handle the collision itself while returning OK(). async fn start_watch( self, server: impl MinecraftServerHandle, From e403d93dc28a9fc541195996522e024a5270fda5 Mon Sep 17 00:00:00 2001 From: Tamipes Date: Thu, 29 Jan 2026 09:56:21 +0100 Subject: [PATCH 2/2] fix: `login_username_extract` span added for extended logging information --- src/main.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index f4f7e31..d54c5c8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -115,8 +115,18 @@ async fn process_connection( packets::ProtocolState::Login => { // This block of packet parsing is needed here, so the span with the // username is correctly propagated due to the async nature of things - let packet = Packet::parse(&mut client_stream).await?; + let span = tracing::span!( + tracing::Level::INFO, + "login_username_extract", + server_addr = handshake.get_server_address(), + server_port = handshake.server_port.get_value() + ); + + let packet = Packet::parse(&mut client_stream) + .instrument(span.clone()) + .await?; let login_packet = packets::serverbound::login::LoginStart::parse(packet) + .instrument(span.clone()) .await .ok_or("Failed to parse login start packet".to_string())?; handle_login(&mut client_stream, &handshake, login_packet, api).await?