Class PacketTracker
java.lang.Object
com.viaversion.viaversion.api.protocol.packet.PacketTracker
Tracks packet count/packet size.
Every second, the current rate of that second is put into a sliding window to be checked against a sustained max rate. After a sufficient amount of hits to the max rate during a configured time period, a connection will be kicked.
Next to the sustained tracking, the current count per second is also constantly checked against its respective max rate per second.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanlongintlonglongbooleanDeprecated, for removal: This API element is subject to removal in a future version.booleanincrementReceived(int packetSize) Increments the number of packets and packet size received by clients.voidIncrements the number of packets sent to the client.booleanvoidreset()voidsetIntervalPackets(long intervalPackets) voidsetPacketLimiterEnabled(boolean packetLimiterEnabled) voidsetReceivedPackets(long receivedPackets) Deprecated, for removal: This API element is subject to removal in a future version.voidsetSentPackets(long sentPackets) Deprecated, for removal: This API element is subject to removal in a future version.voidsetWarnings(int warnings) Deprecated, for removal: This API element is subject to removal in a future version.
-
Constructor Details
-
PacketTracker
-
-
Method Details
-
incrementSent
public void incrementSent()Increments the number of packets sent to the client. -
incrementReceived
Deprecated, for removal: This API element is subject to removal in a future version. -
incrementReceived
public boolean incrementReceived(int packetSize) Increments the number of packets and packet size received by clients. This is either added to the current second, or processed into the rate over multiple seconds.- Returns:
- true if the interval has reset after a second has passed since the last update
-
exceedsLimits
public boolean exceedsLimits() -
getSentPackets
public long getSentPackets() -
setSentPackets
Deprecated, for removal: This API element is subject to removal in a future version. -
getReceivedPackets
public long getReceivedPackets() -
setReceivedPackets
Deprecated, for removal: This API element is subject to removal in a future version. -
getIntervalPackets
public long getIntervalPackets() -
setIntervalPackets
public void setIntervalPackets(long intervalPackets) -
getPacketsPerSecond
public int getPacketsPerSecond() -
isPacketLimiterEnabled
public boolean isPacketLimiterEnabled() -
setPacketLimiterEnabled
public void setPacketLimiterEnabled(boolean packetLimiterEnabled) -
setWarnings
Deprecated, for removal: This API element is subject to removal in a future version. -
reset
public void reset()
-