Added config option to disable ViaProxy transfer packet rewriting

This commit is contained in:
RaphiMC 2025-04-04 00:14:46 +02:00
parent 45dcdfdc98
commit 80c970698d
No known key found for this signature in database
GPG key ID: 0F6BB0657A03AC94
2 changed files with 17 additions and 1 deletions
src/main/java/net/raphimc/viaproxy
protocoltranslator/viaproxy
proxy/client2proxy

View file

@ -155,6 +155,13 @@ public class ViaProxyConfig {
})
private boolean bungeecordPlayerInfoPassthrough = false;
@Option("rewrite-transfer-packets")
@Description({
"Enabling this will rewrite transfer packets to point back to ViaProxy. This allows ViaProxy to perform protocol translation when forwarding the player to the actual server from the transfer packet.",
"This should be left enabled unless you are a server owner and the servers you are transferring to perform their own protocol translation."
})
private boolean rewriteTransferPackets = true;
@Option("custom-motd")
@Description("Custom MOTD to send when clients ping the proxy. Leave empty to use the target server's MOTD.")
private String customMotd = "";
@ -454,6 +461,15 @@ public class ViaProxyConfig {
this.save();
}
public boolean shouldRewriteTransferPackets() {
return this.rewriteTransferPackets;
}
public void setRewriteTransferPackets(final boolean rewriteTransferPackets) {
this.rewriteTransferPackets = rewriteTransferPackets;
this.save();
}
public String getCustomMotd() {
return this.customMotd;
}

View file

@ -269,7 +269,7 @@ public class Client2ProxyHandler extends SimpleChannelInboundHandler<Packet> {
this.proxyConnection.getPacketHandlers().add(new CompressionPacketHandler(this.proxyConnection));
this.proxyConnection.getPacketHandlers().add(new LoginPacketHandler(this.proxyConnection));
this.proxyConnection.getPacketHandlers().add(new DisconnectPacketHandler(this.proxyConnection));
if (clientVersion.newerThanOrEqualTo(ProtocolVersion.v1_20_5)) {
if (ViaProxy.getConfig().shouldRewriteTransferPackets() && clientVersion.newerThanOrEqualTo(ProtocolVersion.v1_20_5)) {
this.proxyConnection.getPacketHandlers().add(new TransferPacketHandler(this.proxyConnection));
}
if (clientVersion.newerThanOrEqualTo(ProtocolVersion.v1_20_2) || serverVersion.newerThanOrEqualTo(ProtocolVersion.v1_20_2)) {