mirror of
https://github.com/ViaVersion/ViaProxy.git
synced 2024-10-03 05:07:36 +02:00
Added option to ignore packet translation errors
This commit is contained in:
parent
05bb19bdd0
commit
73f2e96201
@ -52,6 +52,7 @@ public class Options {
|
||||
public static String CLASSIC_MP_PASS;
|
||||
public static Boolean LEGACY_SKIN_LOADING;
|
||||
public static boolean CHAT_SIGNING;
|
||||
public static boolean IGNORE_PACKET_TRANSLATION_ERRORS;
|
||||
|
||||
// CLI only config options
|
||||
public static int COMPRESSION_THRESHOLD = 256;
|
||||
|
@ -18,6 +18,7 @@
|
||||
package net.raphimc.viaproxy.protocolhack.impl;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import net.raphimc.netminecraft.constants.MCPipeline;
|
||||
import net.raphimc.vialoader.netty.VLPipeline;
|
||||
import net.raphimc.vialoader.util.VersionEnum;
|
||||
@ -28,6 +29,11 @@ public class ViaProxyVLPipeline extends VLPipeline {
|
||||
super(user, version);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelHandler createViaCodec() {
|
||||
return new ViaProxyViaCodec(this.user);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String compressionCodecName() {
|
||||
return MCPipeline.COMPRESSION_HANDLER_NAME;
|
||||
|
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* This file is part of ViaProxy - https://github.com/RaphiMC/ViaProxy
|
||||
* Copyright (C) 2023 RK_01/RaphiMC and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.raphimc.viaproxy.protocolhack.impl;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import net.raphimc.vialoader.netty.ViaCodec;
|
||||
import net.raphimc.viaproxy.cli.options.Options;
|
||||
import net.raphimc.viaproxy.util.logging.Logger;
|
||||
|
||||
public class ViaProxyViaCodec extends ViaCodec {
|
||||
|
||||
public ViaProxyViaCodec(UserConnection user) {
|
||||
super(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
if (Options.IGNORE_PACKET_TRANSLATION_ERRORS) {
|
||||
try {
|
||||
super.channelRead(ctx, msg);
|
||||
} catch (Throwable e) {
|
||||
Logger.LOGGER.error("ProtocolHack packet translation error occurred", e);
|
||||
}
|
||||
} else {
|
||||
super.channelRead(ctx, msg);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -41,6 +41,7 @@ public class AdvancedTab extends AUITab {
|
||||
JCheckBox proxyOnlineMode;
|
||||
JCheckBox legacySkinLoading;
|
||||
JCheckBox chatSigning;
|
||||
JCheckBox ignorePacketTranslationErrors;
|
||||
JButton viaVersionDumpButton;
|
||||
JButton uploadLogsButton;
|
||||
|
||||
@ -104,6 +105,15 @@ public class AdvancedTab extends AUITab {
|
||||
ViaProxy.saveManager.uiSave.loadCheckBox("chat_signing", this.chatSigning);
|
||||
contentPane.add(this.chatSigning);
|
||||
}
|
||||
{
|
||||
this.ignorePacketTranslationErrors = new JCheckBox("Ignore packet translation errors");
|
||||
this.ignorePacketTranslationErrors.setBounds(10, 200, 465, 20);
|
||||
this.ignorePacketTranslationErrors.setToolTipText("Enabling this will prevent getting disconnected from the server when a packet translation error occurs and instead only print the error in the console.\n" +
|
||||
"This may cause issues depending on the type of packet which failed to translate.");
|
||||
this.ignorePacketTranslationErrors.setSelected(false);
|
||||
ViaProxy.saveManager.uiSave.loadCheckBox("ignore_packet_translation_errors", this.ignorePacketTranslationErrors);
|
||||
contentPane.add(this.ignorePacketTranslationErrors);
|
||||
}
|
||||
{
|
||||
this.viaVersionDumpButton = new JButton("Create ViaVersion dump");
|
||||
this.viaVersionDumpButton.setBounds(10, 250, 225, 20);
|
||||
@ -174,6 +184,7 @@ public class AdvancedTab extends AUITab {
|
||||
save.put("proxy_online_mode", String.valueOf(this.proxyOnlineMode.isSelected()));
|
||||
save.put("legacy_skin_loading", String.valueOf(this.legacySkinLoading.isSelected()));
|
||||
save.put("chat_signing", String.valueOf(this.chatSigning.isSelected()));
|
||||
save.put("ignore_packet_translation_errors", String.valueOf(this.ignorePacketTranslationErrors.isSelected()));
|
||||
ViaProxy.saveManager.save();
|
||||
}
|
||||
|
||||
|
@ -191,6 +191,7 @@ public class GeneralTab extends AUITab {
|
||||
ViaProxy.ui.advancedTab.proxy.setEnabled(state);
|
||||
ViaProxy.ui.advancedTab.legacySkinLoading.setEnabled(state);
|
||||
ViaProxy.ui.advancedTab.chatSigning.setEnabled(state);
|
||||
ViaProxy.ui.advancedTab.ignorePacketTranslationErrors.setEnabled(state);
|
||||
if (state) this.serverVersion.getActionListeners()[0].actionPerformed(null);
|
||||
}
|
||||
|
||||
@ -232,6 +233,7 @@ public class GeneralTab extends AUITab {
|
||||
final boolean legacySkinLoading = ViaProxy.ui.advancedTab.legacySkinLoading.isSelected();
|
||||
final String proxyUrl = ViaProxy.ui.advancedTab.proxy.getText().trim();
|
||||
final boolean chatSigning = ViaProxy.ui.advancedTab.chatSigning.isSelected();
|
||||
final boolean ignorePacketTranslationErrors = ViaProxy.ui.advancedTab.ignorePacketTranslationErrors.isSelected();
|
||||
|
||||
try {
|
||||
try {
|
||||
@ -270,6 +272,7 @@ public class GeneralTab extends AUITab {
|
||||
Options.LEGACY_SKIN_LOADING = legacySkinLoading;
|
||||
Options.OPENAUTHMOD_AUTH = authMethod == 2;
|
||||
Options.CHAT_SIGNING = chatSigning;
|
||||
Options.IGNORE_PACKET_TRANSLATION_ERRORS = ignorePacketTranslationErrors;
|
||||
|
||||
if (!proxyUrl.isEmpty()) {
|
||||
try {
|
||||
|
Loading…
Reference in New Issue
Block a user