Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-28 00:50:13 +01:00
Disable VV packet limiter on 1.17.1+ Paper
Dieser Commit ist enthalten in:
Ursprung
f2147179c2
Commit
a0b19872f8
@ -64,7 +64,7 @@ public interface ViaAPI<T> {
|
|||||||
* @return API version incremented with meaningful API changes
|
* @return API version incremented with meaningful API changes
|
||||||
*/
|
*/
|
||||||
default int apiVersion() {
|
default int apiVersion() {
|
||||||
return 5;
|
return 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -297,6 +297,20 @@ public interface UserConnection {
|
|||||||
*/
|
*/
|
||||||
boolean shouldApplyBlockProtocol();
|
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
|
* 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}.
|
* transformig its contents if used together with {@link PacketWrapper#PASSTHROUGH_ID}.
|
||||||
|
@ -19,6 +19,7 @@ package com.viaversion.viaversion.bukkit.handlers;
|
|||||||
|
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||||
import com.viaversion.viaversion.bukkit.classgenerator.ClassGenerator;
|
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.classgenerator.generated.HandlerConstructor;
|
||||||
import com.viaversion.viaversion.connection.UserConnectionImpl;
|
import com.viaversion.viaversion.connection.UserConnectionImpl;
|
||||||
import com.viaversion.viaversion.protocol.ProtocolPipelineImpl;
|
import com.viaversion.viaversion.protocol.ProtocolPipelineImpl;
|
||||||
@ -59,6 +60,10 @@ public class BukkitChannelInitializer extends ChannelInitializer<Channel> {
|
|||||||
UserConnection connection = new UserConnectionImpl(channel);
|
UserConnection connection = new UserConnectionImpl(channel);
|
||||||
new ProtocolPipelineImpl(connection);
|
new ProtocolPipelineImpl(connection);
|
||||||
|
|
||||||
|
if (PaperViaInjector.PAPER_PACKET_LIMITER) {
|
||||||
|
connection.setPacketLimiterEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
// Add our transformers
|
// Add our transformers
|
||||||
HandlerConstructor constructor = ClassGenerator.getConstructor();
|
HandlerConstructor constructor = ClassGenerator.getConstructor();
|
||||||
MessageToByteEncoder encoder = constructor.newEncodeHandler(connection, (MessageToByteEncoder) channel.pipeline().get("encoder"));
|
MessageToByteEncoder encoder = constructor.newEncodeHandler(connection, (MessageToByteEncoder) channel.pipeline().get("encoder"));
|
||||||
|
@ -27,6 +27,7 @@ import java.lang.reflect.Proxy;
|
|||||||
public final class PaperViaInjector {
|
public final class PaperViaInjector {
|
||||||
public static final boolean PAPER_INJECTION_METHOD = hasPaperInjectionMethod();
|
public static final boolean PAPER_INJECTION_METHOD = hasPaperInjectionMethod();
|
||||||
public static final boolean PAPER_PROTOCOL_METHOD = hasServerProtocolMethod();
|
public static final boolean PAPER_PROTOCOL_METHOD = hasServerProtocolMethod();
|
||||||
|
public static final boolean PAPER_PACKET_LIMITER = hasPacketLimiter();
|
||||||
|
|
||||||
private PaperViaInjector() {
|
private PaperViaInjector() {
|
||||||
}
|
}
|
||||||
@ -64,8 +65,16 @@ public final class PaperViaInjector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static boolean hasPaperInjectionMethod() {
|
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 {
|
try {
|
||||||
Class.forName("io.papermc.paper.network.ChannelInitializeListener");
|
Class.forName(className);
|
||||||
return true;
|
return true;
|
||||||
} catch (ReflectiveOperationException e) {
|
} catch (ReflectiveOperationException e) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -63,6 +63,7 @@ public class UserConnectionImpl implements UserConnection {
|
|||||||
private final boolean clientSide;
|
private final boolean clientSide;
|
||||||
private boolean active = true;
|
private boolean active = true;
|
||||||
private boolean pendingDisconnect;
|
private boolean pendingDisconnect;
|
||||||
|
private boolean packetLimiterEnabled = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an UserConnection. When it's a client-side connection, some method behaviors are modified.
|
* 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
|
@Override
|
||||||
public boolean checkServerboundPacket() {
|
public boolean checkServerboundPacket() {
|
||||||
// Ignore if pending disconnect
|
if (pendingDisconnect || !packetLimiterEnabled) {
|
||||||
if (pendingDisconnect) return false;
|
return false;
|
||||||
|
}
|
||||||
// Increment received + Check PPS
|
// Increment received + Check PPS
|
||||||
return !packetTracker.incrementReceived() || !packetTracker.exceedsMaxPPS();
|
return !packetTracker.incrementReceived() || !packetTracker.exceedsMaxPPS();
|
||||||
}
|
}
|
||||||
@ -357,6 +359,16 @@ public class UserConnectionImpl implements UserConnection {
|
|||||||
return !clientSide; // Don't apply protocol blocking on client-side
|
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
|
@Override
|
||||||
public UUID generatePassthroughToken() {
|
public UUID generatePassthroughToken() {
|
||||||
UUID token = UUID.randomUUID();
|
UUID token = UUID.randomUUID();
|
||||||
|
@ -72,7 +72,7 @@ velocity-servers: {}
|
|||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# GLOBAL PACKET LIMITER #
|
# 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)
|
# 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.
|
# Clients by default send around 20-90 packets per second.
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren