diff --git a/proxy/changelog.md b/proxy/changelog.md index 69ba0ade..8c44a4ac 100644 --- a/proxy/changelog.md +++ b/proxy/changelog.md @@ -6,4 +6,5 @@ Versions 2.0.x and 2.1.x are protocol-compatible, so there’s no need to worry if the server hasn't been updated to 2.1.x. ### Changes in 2.1.2 -- Fixed buffer overflow when using AudioSender with delayed first frame. \ No newline at end of file +- Fixed buffer overflow when using AudioSender with delayed first frame. +- Fixed client EncoderException on server switch caused by UDP packets sent to a client when client's server is null. \ No newline at end of file diff --git a/proxy/common/src/main/java/su/plo/voice/proxy/socket/NettyPacketHandler.java b/proxy/common/src/main/java/su/plo/voice/proxy/socket/NettyPacketHandler.java index ef091696..8a27bd41 100644 --- a/proxy/common/src/main/java/su/plo/voice/proxy/socket/NettyPacketHandler.java +++ b/proxy/common/src/main/java/su/plo/voice/proxy/socket/NettyPacketHandler.java @@ -128,6 +128,8 @@ private boolean sendPacket(ChannelHandlerContext ctx, NettyPacketUdp nettyPacket } else { receiver = connection.getRemoteAddress(); receiverSecret = connection.getSecret(); + + if (!connection.isConnected()) return true; } // rewrite to backend server diff --git a/proxy/common/src/main/java/su/plo/voice/proxy/socket/NettyUdpProxyConnection.java b/proxy/common/src/main/java/su/plo/voice/proxy/socket/NettyUdpProxyConnection.java index ae90a5b7..f483db06 100644 --- a/proxy/common/src/main/java/su/plo/voice/proxy/socket/NettyUdpProxyConnection.java +++ b/proxy/common/src/main/java/su/plo/voice/proxy/socket/NettyUdpProxyConnection.java @@ -42,7 +42,6 @@ public final class NettyUdpProxyConnection implements UdpProxyConnection, Server private InetSocketAddress remoteAddress; @Setter private RemoteServer remoteServer; - @Getter private boolean connected = true; @Override @@ -52,6 +51,8 @@ public Optional getRemoteServer() { @Override public void sendPacket(Packet packet) { + if (!isConnected()) return; + byte[] encoded = PacketUdpCodec.encode(packet, secret); if (encoded == null) return; @@ -70,6 +71,11 @@ public void disconnect() { this.connected = false; } + @Override + public boolean isConnected() { + return connected && player.getInstance().getServer() != null; + } + @Override public void handle(@NotNull PingPacket packet) { }