From b5d228028c866767e835e3ae0494f67740a936ee Mon Sep 17 00:00:00 2001 From: creeper123123321 Date: Fri, 8 Mar 2019 08:33:28 -0300 Subject: [PATCH 1/2] untested control handler --- .../proxy/connection/backend/VelocityServerConnection.java | 3 +++ .../java/com/velocitypowered/proxy/network/Connections.java | 1 + 2 files changed, 4 insertions(+) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/VelocityServerConnection.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/VelocityServerConnection.java index 0eae3f0c8..8471b2252 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/VelocityServerConnection.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/VelocityServerConnection.java @@ -2,6 +2,7 @@ package com.velocitypowered.proxy.connection.backend; import static com.velocitypowered.proxy.VelocityServer.GSON; import static com.velocitypowered.proxy.connection.forge.legacy.LegacyForgeConstants.HANDSHAKE_HOSTNAME_TOKEN; +import static com.velocitypowered.proxy.network.Connections.FLOW_HANDLER; import static com.velocitypowered.proxy.network.Connections.FRAME_DECODER; import static com.velocitypowered.proxy.network.Connections.FRAME_ENCODER; import static com.velocitypowered.proxy.network.Connections.HANDLER; @@ -34,6 +35,7 @@ import com.velocitypowered.proxy.server.VelocityRegisteredServer; import io.netty.channel.Channel; import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelInitializer; +import io.netty.handler.flow.FlowControlHandler; import io.netty.handler.timeout.ReadTimeoutHandler; import java.util.concurrent.CompletableFuture; import java.util.concurrent.TimeUnit; @@ -83,6 +85,7 @@ public class VelocityServerConnection implements MinecraftConnectionAssociation, TimeUnit.MILLISECONDS)) .addLast(FRAME_DECODER, new MinecraftVarintFrameDecoder()) .addLast(FRAME_ENCODER, MinecraftVarintLengthEncoder.INSTANCE) + .addLast(FLOW_HANDLER, new FlowControlHandler()) .addLast(MINECRAFT_DECODER, new MinecraftDecoder(ProtocolUtils.Direction.CLIENTBOUND)) .addLast(MINECRAFT_ENCODER, diff --git a/proxy/src/main/java/com/velocitypowered/proxy/network/Connections.java b/proxy/src/main/java/com/velocitypowered/proxy/network/Connections.java index 8f7a6c278..33112a089 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/network/Connections.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/Connections.java @@ -6,6 +6,7 @@ public class Connections { public static final String CIPHER_ENCODER = "cipher-encoder"; public static final String COMPRESSION_DECODER = "compression-decoder"; public static final String COMPRESSION_ENCODER = "compression-encoder"; + public static final String FLOW_HANDLER = "flow-handler"; public static final String FRAME_DECODER = "frame-decoder"; public static final String FRAME_ENCODER = "frame-encoder"; public static final String HANDLER = "handler"; From 30df2ad04bca1cf3bad6b7b80b3ce770ce527a0f Mon Sep 17 00:00:00 2001 From: creeper123123321 Date: Fri, 8 Mar 2019 08:48:03 -0300 Subject: [PATCH 2/2] Request read after setting auto-read to true --- .../proxy/connection/backend/LoginSessionHandler.java | 1 + 1 file changed, 1 insertion(+) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/LoginSessionHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/LoginSessionHandler.java index 117d1c15d..2024ccfc9 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/LoginSessionHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/LoginSessionHandler.java @@ -136,6 +136,7 @@ public class LoginSessionHandler implements MinecraftSessionHandler { smc.setSessionHandler(new BackendPlaySessionHandler(server, serverConn)); serverConn.getPlayer().setConnectedServer(serverConn); smc.getChannel().config().setAutoRead(true); + smc.getChannel().read(); }, smc.eventLoop()); return true; }