Skip to content

Commit 14599bf

Browse files
committed
Fixed Simple Voice Chat address rewriting when the server uses a numeric IP address
Fixes #549
1 parent 4c649a4 commit 14599bf

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/main/java/net/raphimc/viaproxy/proxy/packethandler/SimpleVoiceChatPacketHandler.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import net.raphimc.netminecraft.packet.PacketTypes;
2727
import net.raphimc.netminecraft.packet.impl.common.S2CCustomPayloadPacket;
2828
import net.raphimc.viaproxy.proxy.session.ProxyConnection;
29+
import net.raphimc.viaproxy.util.AddressUtil;
2930
import net.raphimc.viaproxy.util.logging.Logger;
3031

3132
import java.net.InetSocketAddress;
@@ -58,7 +59,9 @@ public boolean handleP2S(Packet packet, List<ChannelFutureListener> listeners) t
5859
final String voiceHost = PacketTypes.readString(data, Short.MAX_VALUE); // voice host
5960
if (voiceHost.isEmpty()) {
6061
if (this.proxyConnection.getServerAddress() instanceof InetSocketAddress serverAddress) {
61-
PacketTypes.writeString(newData, new InetSocketAddress(serverAddress.getAddress(), port).toString());
62+
final String newVoiceHost = AddressUtil.toString(new InetSocketAddress(serverAddress.getAddress(), port));
63+
PacketTypes.writeString(newData, newVoiceHost);
64+
Logger.u_info("session", this.proxyConnection, "Redirecting Simple Voice Chat to " + newVoiceHost);
6265
} else {
6366
throw new IllegalArgumentException("Server address must be an InetSocketAddress");
6467
}
@@ -68,7 +71,7 @@ public boolean handleP2S(Packet packet, List<ChannelFutureListener> listeners) t
6871
newData.writeBytes(data);
6972
customPayloadPacket.data = ByteBufUtil.getBytes(newData);
7073
} catch (Throwable e) {
71-
Logger.LOGGER.error("Failed to handle simple voice chat packet", e);
74+
Logger.LOGGER.error("Failed to handle Simple Voice Chat packet", e);
7275
}
7376
}
7477
}

0 commit comments

Comments
 (0)