mirror of
https://github.com/ViaVersion/ViaProxy.git
synced 2024-11-26 17:36:21 -05:00
Fixed packets being sent too early after connecting
This commit is contained in:
parent
58b4819677
commit
25b341a545
2 changed files with 18 additions and 14 deletions
|
@ -229,18 +229,20 @@ public class Client2ProxyHandler extends SimpleChannelInboundHandler<IPacket> {
|
||||||
|
|
||||||
this.proxyConnection.connectToServer(serverAddress, serverVersion).addListeners((ThrowingChannelFutureListener) f -> {
|
this.proxyConnection.connectToServer(serverAddress, serverVersion).addListeners((ThrowingChannelFutureListener) f -> {
|
||||||
if (f.isSuccess()) {
|
if (f.isSuccess()) {
|
||||||
if (Options.SERVER_HAPROXY_PROTOCOL) {
|
f.channel().eventLoop().submit(() -> { // Reschedule so the packets get sent after the channel is fully initialized and active
|
||||||
this.proxyConnection.getChannel().writeAndFlush(HAProxyUtil.createMessage(this.proxyConnection.getC2P(), this.proxyConnection.getChannel(), clientVersion)).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE);
|
if (Options.SERVER_HAPROXY_PROTOCOL) {
|
||||||
}
|
this.proxyConnection.getChannel().writeAndFlush(HAProxyUtil.createMessage(this.proxyConnection.getC2P(), this.proxyConnection.getChannel(), clientVersion)).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE);
|
||||||
|
|
||||||
handshakeParts[0] = serverAddress.getAddress();
|
|
||||||
this.proxyConnection.getChannel().writeAndFlush(new C2SHandshakePacket(clientVersion.getOriginalVersion(), String.join("\0", handshakeParts), serverAddress.getPort(), packet.intendedState)).addListeners(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE, (ChannelFutureListener) f2 -> {
|
|
||||||
if (f2.isSuccess()) {
|
|
||||||
this.proxyConnection.setP2sConnectionState(packet.intendedState);
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
ChannelUtil.restoreAutoRead(this.proxyConnection.getC2P());
|
handshakeParts[0] = serverAddress.getAddress();
|
||||||
|
this.proxyConnection.getChannel().writeAndFlush(new C2SHandshakePacket(clientVersion.getOriginalVersion(), String.join("\0", handshakeParts), serverAddress.getPort(), packet.intendedState)).addListeners(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE, (ChannelFutureListener) f2 -> {
|
||||||
|
if (f2.isSuccess()) {
|
||||||
|
this.proxyConnection.setP2sConnectionState(packet.intendedState);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
ChannelUtil.restoreAutoRead(this.proxyConnection.getC2P());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}, (ThrowingChannelFutureListener) f -> {
|
}, (ThrowingChannelFutureListener) f -> {
|
||||||
if (!f.isSuccess()) {
|
if (!f.isSuccess()) {
|
||||||
|
|
|
@ -82,11 +82,13 @@ public class PassthroughClient2ProxyHandler extends SimpleChannelInboundHandler<
|
||||||
|
|
||||||
this.proxyConnection.connect(serverAddress).addListeners((ThrowingChannelFutureListener) f -> {
|
this.proxyConnection.connect(serverAddress).addListeners((ThrowingChannelFutureListener) f -> {
|
||||||
if (f.isSuccess()) {
|
if (f.isSuccess()) {
|
||||||
if (Options.SERVER_HAPROXY_PROTOCOL) {
|
f.channel().eventLoop().submit(() -> { // Reschedule so the packets get sent after the channel is fully initialized and active
|
||||||
this.proxyConnection.getChannel().writeAndFlush(HAProxyUtil.createMessage(this.proxyConnection.getC2P(), this.proxyConnection.getChannel(), null)).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE);
|
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());
|
ChannelUtil.restoreAutoRead(this.proxyConnection.getC2P());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}, (ThrowingChannelFutureListener) f -> {
|
}, (ThrowingChannelFutureListener) f -> {
|
||||||
if (!f.isSuccess()) {
|
if (!f.isSuccess()) {
|
||||||
|
|
Loading…
Reference in a new issue