Fixed packets being sent too early after connecting

This commit is contained in:
RaphiMC 2023-10-03 20:20:49 +02:00
parent 58b4819677
commit 25b341a545
No known key found for this signature in database
GPG key ID: 0F6BB0657A03AC94
2 changed files with 18 additions and 14 deletions

View file

@ -229,6 +229,7 @@ public class Client2ProxyHandler extends SimpleChannelInboundHandler<IPacket> {
this.proxyConnection.connectToServer(serverAddress, serverVersion).addListeners((ThrowingChannelFutureListener) f -> {
if (f.isSuccess()) {
f.channel().eventLoop().submit(() -> { // Reschedule so the packets get sent after the channel is fully initialized and active
if (Options.SERVER_HAPROXY_PROTOCOL) {
this.proxyConnection.getChannel().writeAndFlush(HAProxyUtil.createMessage(this.proxyConnection.getC2P(), this.proxyConnection.getChannel(), clientVersion)).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE);
}
@ -241,6 +242,7 @@ public class Client2ProxyHandler extends SimpleChannelInboundHandler<IPacket> {
});
ChannelUtil.restoreAutoRead(this.proxyConnection.getC2P());
});
}
}, (ThrowingChannelFutureListener) f -> {
if (!f.isSuccess()) {

View file

@ -82,11 +82,13 @@ public class PassthroughClient2ProxyHandler extends SimpleChannelInboundHandler<
this.proxyConnection.connect(serverAddress).addListeners((ThrowingChannelFutureListener) f -> {
if (f.isSuccess()) {
f.channel().eventLoop().submit(() -> { // Reschedule so the packets get sent after the channel is fully initialized and active
if (Options.SERVER_HAPROXY_PROTOCOL) {
this.proxyConnection.getChannel().writeAndFlush(HAProxyUtil.createMessage(this.proxyConnection.getC2P(), this.proxyConnection.getChannel(), null)).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE);
}
ChannelUtil.restoreAutoRead(this.proxyConnection.getC2P());
});
}
}, (ThrowingChannelFutureListener) f -> {
if (!f.isSuccess()) {