From 93f8367c5d494cefc498c4ff4659cee7be1d8c9a Mon Sep 17 00:00:00 2001 From: Jannis Guhl <128991638+guhlutions@users.noreply.github.com> Date: Fri, 13 Nov 2026 22:49:59 +0100 Subject: [PATCH] Answer status pings locally for Xbox Bedrock sessions --- .../client2proxy/Client2ProxyHandler.java | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/raphimc/viaproxy/proxy/client2proxy/Client2ProxyHandler.java b/src/main/java/net/raphimc/viaproxy/proxy/client2proxy/Client2ProxyHandler.java index 65466397..68314577 100644 --- a/src/main/java/net/raphimc/viaproxy/proxy/client2proxy/Client2ProxyHandler.java +++ b/src/main/java/net/raphimc/viaproxy/proxy/client2proxy/Client2ProxyHandler.java @@ -34,6 +34,8 @@ import net.raphimc.netminecraft.constants.IntendedState; import net.raphimc.netminecraft.packet.Packet; import net.raphimc.netminecraft.packet.impl.handshaking.C2SHandshakingClientIntentionPacket; +import net.raphimc.netminecraft.packet.impl.status.C2SStatusPingRequestPacket; +import net.raphimc.netminecraft.packet.impl.status.C2SStatusRequestPacket; import net.raphimc.netminecraft.packet.impl.status.S2CStatusPongResponsePacket; import net.raphimc.netminecraft.packet.impl.status.S2CStatusResponsePacket; import net.raphimc.viabedrock.api.BedrockProtocolVersion; @@ -55,6 +57,8 @@ import net.raphimc.viaproxy.proxy.util.*; import net.raphimc.viaproxy.saves.impl.accounts.ClassicAccount; import net.raphimc.viaproxy.util.*; +import net.raphimc.viaproxy.util.address.NetherNetXboxAddress; +import net.raphimc.viaproxy.util.address.NetherNetXboxJsonRpcAddress; import net.raphimc.viaproxy.util.logging.Logger; import java.net.InetSocketAddress; @@ -65,6 +69,8 @@ public class Client2ProxyHandler extends SimpleChannelInboundHandler { private ProxyConnection proxyConnection; + private S2CStatusResponsePacket localStatusResponse; + private boolean localStatusSent; @Override public void channelActive(ChannelHandlerContext ctx) throws Exception { @@ -89,6 +95,18 @@ public void channelInactive(ChannelHandlerContext ctx) throws Exception { protected void channelRead0(ChannelHandlerContext ctx, Packet packet) throws Exception { if (this.proxyConnection.isClosed()) return; + if (this.localStatusResponse != null) { + if (packet instanceof C2SStatusRequestPacket && !this.localStatusSent) { + this.localStatusSent = true; + ctx.writeAndFlush(this.localStatusResponse).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE); + } else if (packet instanceof C2SStatusPingRequestPacket ping && this.localStatusSent) { + ctx.writeAndFlush(new S2CStatusPongResponsePacket(ping.startTime)).addListener(ChannelFutureListener.CLOSE); + } else { + ctx.close(); + } + return; + } + if (this.proxyConnection.getC2pConnectionState() == ConnectionState.HANDSHAKING) { if (packet instanceof C2SHandshakingClientIntentionPacket) this.handleHandshake((C2SHandshakingClientIntentionPacket) packet); else throw new IllegalStateException("Unexpected packet in HANDSHAKING state"); @@ -191,10 +209,22 @@ private void handleHandshake(final C2SHandshakingClientIntentionPacket packet) { serverAddress = preConnectEvent.getServerAddress(); serverVersion = preConnectEvent.getServerVersion(); + final boolean isBedrockPing = packet.intendedState.getConnectionState() == ConnectionState.STATUS && serverVersion.equals(BedrockProtocolVersion.BEDROCK_LATEST); + if (isBedrockPing && (serverAddress instanceof NetherNetXboxAddress || serverAddress instanceof NetherNetXboxJsonRpcAddress)) { + // Xbox signaling addresses identify sessions. Only dedicated servers expose the HTTP status endpoint. + final MCPingResponse response = new MCPingResponse(); + response.version = new MCPingResponse.Version(); + response.version.name = "ViaProxy"; + response.version.protocol = clientVersion.getOriginalVersion(); + final String customMotd = ViaProxy.getConfig().getCustomMotd(); + response.description = customMotd.isBlank() ? "ViaProxy ยท Bedrock via Xbox Live" : customMotd; + this.localStatusResponse = new S2CStatusResponsePacket(new Gson().toJson(response)); + return; + } + ChannelUtil.disableAutoRead(this.proxyConnection.getC2P()); final boolean isJavaBetaPing = packet.intendedState.getConnectionState() == ConnectionState.STATUS && serverVersion.olderThanOrEqualTo(LegacyProtocolVersion.b1_7tob1_7_3) && !ViaProxy.getConfig().shouldAllowBetaPinging(); - final boolean isBedrockPing = packet.intendedState.getConnectionState() == ConnectionState.STATUS && serverVersion.equals(BedrockProtocolVersion.BEDROCK_LATEST); if (isJavaBetaPing || isBedrockPing) { if (!ViaProxy.getConfig().getCustomMotd().isBlank()) { this.proxyConnection.kickClient(ViaProxy.getConfig().getCustomMotd());