3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-27 08:30:09 +01:00

Disable VV packet limiter on 1.17.1+ Paper

Dieser Commit ist enthalten in:
Nassim Jahnke 2021-09-01 15:25:24 +02:00
Ursprung f2147179c2
Commit a0b19872f8
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 6BE3B555EBC5982B
6 geänderte Dateien mit 45 neuen und 5 gelöschten Zeilen

Datei anzeigen

@ -64,7 +64,7 @@ public interface ViaAPI<T> {
* @return API version incremented with meaningful API changes
*/
default int apiVersion() {
return 5;
return 6;
}
/**

Datei anzeigen

@ -297,6 +297,20 @@ public interface UserConnection {
*/
boolean shouldApplyBlockProtocol();
/**
* Returns whether the packet limiter applies to this user.
*
* @return whether the packet limiter applies to this user
*/
boolean isPacketLimiterEnabled();
/**
* Sets the status of the packet limiter.
*
* @param packetLimiterEnabled whether the packet limiter should be enabled
*/
void setPacketLimiterEnabled(boolean packetLimiterEnabled);
/**
* Returns a newly generated uuid that will let a packet be passed through without
* transformig its contents if used together with {@link PacketWrapper#PASSTHROUGH_ID}.

Datei anzeigen

@ -19,6 +19,7 @@ package com.viaversion.viaversion.bukkit.handlers;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.bukkit.classgenerator.ClassGenerator;
import com.viaversion.viaversion.bukkit.platform.PaperViaInjector;
import com.viaversion.viaversion.classgenerator.generated.HandlerConstructor;
import com.viaversion.viaversion.connection.UserConnectionImpl;
import com.viaversion.viaversion.protocol.ProtocolPipelineImpl;
@ -59,6 +60,10 @@ public class BukkitChannelInitializer extends ChannelInitializer<Channel> {
UserConnection connection = new UserConnectionImpl(channel);
new ProtocolPipelineImpl(connection);
if (PaperViaInjector.PAPER_PACKET_LIMITER) {
connection.setPacketLimiterEnabled(false);
}
// Add our transformers
HandlerConstructor constructor = ClassGenerator.getConstructor();
MessageToByteEncoder encoder = constructor.newEncodeHandler(connection, (MessageToByteEncoder) channel.pipeline().get("encoder"));

Datei anzeigen

@ -27,6 +27,7 @@ import java.lang.reflect.Proxy;
public final class PaperViaInjector {
public static final boolean PAPER_INJECTION_METHOD = hasPaperInjectionMethod();
public static final boolean PAPER_PROTOCOL_METHOD = hasServerProtocolMethod();
public static final boolean PAPER_PACKET_LIMITER = hasPacketLimiter();
private PaperViaInjector() {
}
@ -64,8 +65,16 @@ public final class PaperViaInjector {
}
private static boolean hasPaperInjectionMethod() {
return hasClass("io.papermc.paper.network.ChannelInitializeListener");
}
private static boolean hasPacketLimiter() {
return hasClass("com.destroystokyo.paper.PaperConfig$PacketLimit") || hasClass("io.papermc.paper.PaperConfig$PacketLimit");
}
private static boolean hasClass(final String className) {
try {
Class.forName("io.papermc.paper.network.ChannelInitializeListener");
Class.forName(className);
return true;
} catch (ReflectiveOperationException e) {
return false;

Datei anzeigen

@ -63,6 +63,7 @@ public class UserConnectionImpl implements UserConnection {
private final boolean clientSide;
private boolean active = true;
private boolean pendingDisconnect;
private boolean packetLimiterEnabled = true;
/**
* Creates an UserConnection. When it's a client-side connection, some method behaviors are modified.
@ -253,8 +254,9 @@ public class UserConnectionImpl implements UserConnection {
@Override
public boolean checkServerboundPacket() {
// Ignore if pending disconnect
if (pendingDisconnect) return false;
if (pendingDisconnect || !packetLimiterEnabled) {
return false;
}
// Increment received + Check PPS
return !packetTracker.incrementReceived() || !packetTracker.exceedsMaxPPS();
}
@ -357,6 +359,16 @@ public class UserConnectionImpl implements UserConnection {
return !clientSide; // Don't apply protocol blocking on client-side
}
@Override
public boolean isPacketLimiterEnabled() {
return packetLimiterEnabled;
}
@Override
public void setPacketLimiterEnabled(boolean packetLimiterEnabled) {
this.packetLimiterEnabled = packetLimiterEnabled;
}
@Override
public UUID generatePassthroughToken() {
UUID token = UUID.randomUUID();

Datei anzeigen

@ -72,7 +72,7 @@ velocity-servers: {}
#----------------------------------------------------------#
# GLOBAL PACKET LIMITER #
#----------------------------------------------------------#
#
# THIS FEATURE IS DISABLED ON 1.17.1+ PAPER SERVERS, SINCE IT HAS A BETTER PACKET-LIMITER INBUILT
#
# Packets Per Second (PPS) limiter (Use -1 on max-pps and tracking-period to disable)
# Clients by default send around 20-90 packets per second.