Improved handshake address rewriting

This commit is contained in:
RaphiMC 2023-11-04 17:05:54 +01:00
parent 9a41bca967
commit dd1f602e53
No known key found for this signature in database
GPG Key ID: 0F6BB0657A03AC94
2 changed files with 1 additions and 22 deletions

View File

@ -62,7 +62,6 @@ public class Options {
public static String RESOURCE_PACK_URL; // Example: http://example.com/resourcepack.zip
public static boolean SERVER_HAPROXY_PROTOCOL;
public static boolean LEGACY_CLIENT_PASSTHROUGH;
public static boolean PLAYER_INFO_FORWARDING;
public static void parse(final String[] args) throws IOException {
final OptionParser parser = new OptionParser();
@ -84,7 +83,6 @@ public class Options {
final OptionSpec<String> proxyUrl = parser.acceptsAll(asList("proxy_url", "proxy"), "URL of a SOCKS(4/5)/HTTP(S) proxy which will be used for backend TCP connections").withRequiredArg().ofType(String.class);
final OptionSpec<Void> serverHaProxyProtocol = parser.acceptsAll(asList("server-haproxy-protocol", "server-haproxy"), "Send HAProxy protocol messages to the backend server");
final OptionSpec<Void> legacyClientPassthrough = parser.acceptsAll(asList("legacy_client_passthrough", "legacy_passthrough"), "Allow <= 1.6.4 clients to connect to the backend server (No protocol translation)");
final OptionSpec<Void> playerInfoForwarding = parser.acceptsAll(asList("player_info_forwarding", "pif"), "Enabled BungeeCord player info forwarding");
final OptionSpec<Void> ignorePacketTranslationErrors = parser.acceptsAll(List.of("ignore-packet-translation-errors"), "Enabling this will prevent getting disconnected from the server when a packet translation error occurs and instead only print the error in the console. This may cause issues depending on the type of packet which failed to translate");
ViaProxy.EVENT_MANAGER.call(new PreOptionsParseEvent(parser));
@ -147,7 +145,6 @@ public class Options {
}
SERVER_HAPROXY_PROTOCOL = options.has(serverHaProxyProtocol);
LEGACY_CLIENT_PASSTHROUGH = options.has(legacyClientPassthrough);
PLAYER_INFO_FORWARDING = options.has(playerInfoForwarding);
IGNORE_PACKET_TRANSLATION_ERRORS = options.has(ignorePacketTranslationErrors);
ViaProxy.EVENT_MANAGER.call(new PostOptionsParseEvent(options));
} catch (OptionException e) {

View File

@ -114,25 +114,7 @@ public class Client2ProxyHandler extends SimpleChannelInboundHandler<IPacket> {
this.proxyConnection.kickClient("§cYour client version is not supported by ViaProxy!");
}
final String[] handshakeParts;
if (Options.PLAYER_INFO_FORWARDING) {
handshakeParts = new String[3];
final String[] receivedParts = packet.address.split("\0");
for (int i = 0; i < receivedParts.length && i < handshakeParts.length; i++) {
handshakeParts[i] = receivedParts[i];
}
if (handshakeParts[0] == null) {
this.proxyConnection.kickClient("§cMissing hostname in handshake. Ensure that your proxy has player info forwarding enabled.");
}
if (handshakeParts[1] == null) {
this.proxyConnection.kickClient("§cMissing player IP in handshake. Ensure that your proxy has player info forwarding enabled.");
}
if (handshakeParts[2] == null) {
this.proxyConnection.kickClient("§cMissing player UUID in handshake. Ensure that your proxy has player info forwarding enabled.");
}
} else {
handshakeParts = new String[]{packet.address};
}
final String[] handshakeParts = packet.address.split("\0");
String connectIP = Options.CONNECT_ADDRESS;
int connectPort = Options.CONNECT_PORT;