mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-09-18 18:01:17 +02:00
Add limiting of "bursts" in moving.morepackets.
This commit is contained in:
parent
039c4b407f
commit
552beed739
@ -60,7 +60,7 @@ public class MorePackets extends Check {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check for a violation of the set limits.
|
// Check for a violation of the set limits.
|
||||||
final double violation = NetStatic.morePacketsCheck(data.morePacketsFreq, time, 1f, cc.morePacketsEPSMax, cc.morePacketsEPSIdeal);
|
final double violation = NetStatic.morePacketsCheck(data.morePacketsFreq, time, 1f, cc.morePacketsEPSMax, cc.morePacketsEPSIdeal, data.morePacketsBurstFreq, cc.morePacketsBurstPackets, cc.morePacketsBurstEPM);
|
||||||
|
|
||||||
// Process violation result.
|
// Process violation result.
|
||||||
if (violation > 0.0) {
|
if (violation > 0.0) {
|
||||||
|
@ -80,6 +80,8 @@ public class MovingConfig extends ACheckConfig {
|
|||||||
public final float morePacketsEPSIdeal;
|
public final float morePacketsEPSIdeal;
|
||||||
/** The maximum number of packets per second that we accept. */
|
/** The maximum number of packets per second that we accept. */
|
||||||
public final float morePacketsEPSMax;
|
public final float morePacketsEPSMax;
|
||||||
|
public final float morePacketsBurstPackets;
|
||||||
|
public final double morePacketsBurstEPM;
|
||||||
public final ActionList morePacketsActions;
|
public final ActionList morePacketsActions;
|
||||||
|
|
||||||
public final boolean morePacketsVehicleCheck;
|
public final boolean morePacketsVehicleCheck;
|
||||||
@ -173,6 +175,8 @@ public class MovingConfig extends ACheckConfig {
|
|||||||
morePacketsCheck = config.getBoolean(ConfPaths.MOVING_MOREPACKETS_CHECK);
|
morePacketsCheck = config.getBoolean(ConfPaths.MOVING_MOREPACKETS_CHECK);
|
||||||
morePacketsEPSIdeal = config.getInt(ConfPaths.MOVING_MOREPACKETS_EPSIDEAL);
|
morePacketsEPSIdeal = config.getInt(ConfPaths.MOVING_MOREPACKETS_EPSIDEAL);
|
||||||
morePacketsEPSMax = Math.max(morePacketsEPSIdeal, config.getInt(ConfPaths.MOVING_MOREPACKETS_EPSMAX));
|
morePacketsEPSMax = Math.max(morePacketsEPSIdeal, config.getInt(ConfPaths.MOVING_MOREPACKETS_EPSMAX));
|
||||||
|
morePacketsBurstPackets = config.getInt(ConfPaths.MOVING_MOREPACKETS_BURST_PACKETS);
|
||||||
|
morePacketsBurstEPM = config.getInt(ConfPaths.MOVING_MOREPACKETS_BURST_EPM);
|
||||||
morePacketsActions = config.getOptimizedActionList(ConfPaths.MOVING_MOREPACKETS_ACTIONS, Permissions.MOVING_MOREPACKETS);
|
morePacketsActions = config.getOptimizedActionList(ConfPaths.MOVING_MOREPACKETS_ACTIONS, Permissions.MOVING_MOREPACKETS);
|
||||||
|
|
||||||
morePacketsVehicleCheck = config.getBoolean(ConfPaths.MOVING_MOREPACKETSVEHICLE_CHECK);
|
morePacketsVehicleCheck = config.getBoolean(ConfPaths.MOVING_MOREPACKETSVEHICLE_CHECK);
|
||||||
|
@ -148,7 +148,10 @@ public class MovingData extends ACheckData {
|
|||||||
public boolean creativeFlyPreviousRefused;
|
public boolean creativeFlyPreviousRefused;
|
||||||
|
|
||||||
// Data of the more packets check.
|
// Data of the more packets check.
|
||||||
|
/** Packet frequency count. */
|
||||||
public final ActionFrequency morePacketsFreq = new ActionFrequency(10, 500);
|
public final ActionFrequency morePacketsFreq = new ActionFrequency(10, 500);
|
||||||
|
/** Burst count. */
|
||||||
|
public final ActionFrequency morePacketsBurstFreq = new ActionFrequency(12, 5000);
|
||||||
private Location morePacketsSetback = null;
|
private Location morePacketsSetback = null;
|
||||||
|
|
||||||
// Data of the more packets vehicle check.
|
// Data of the more packets vehicle check.
|
||||||
|
@ -505,6 +505,9 @@ public abstract class ConfPaths {
|
|||||||
public static final String MOVING_MOREPACKETS_CHECK = MOVING_MOREPACKETS + "active";
|
public static final String MOVING_MOREPACKETS_CHECK = MOVING_MOREPACKETS + "active";
|
||||||
public static final String MOVING_MOREPACKETS_EPSIDEAL = MOVING_MOREPACKETS + "epsideal";
|
public static final String MOVING_MOREPACKETS_EPSIDEAL = MOVING_MOREPACKETS + "epsideal";
|
||||||
public static final String MOVING_MOREPACKETS_EPSMAX = MOVING_MOREPACKETS + "epsmax";
|
public static final String MOVING_MOREPACKETS_EPSMAX = MOVING_MOREPACKETS + "epsmax";
|
||||||
|
private static final String MOVING_MOREPACKETS_BURST = MOVING_MOREPACKETS + "burst.";
|
||||||
|
public static final String MOVING_MOREPACKETS_BURST_PACKETS = MOVING_MOREPACKETS_BURST + "packets";
|
||||||
|
public static final String MOVING_MOREPACKETS_BURST_EPM = MOVING_MOREPACKETS_BURST + "epmviolation";
|
||||||
public static final String MOVING_MOREPACKETS_ACTIONS = MOVING_MOREPACKETS + "actions";
|
public static final String MOVING_MOREPACKETS_ACTIONS = MOVING_MOREPACKETS + "actions";
|
||||||
|
|
||||||
private static final String MOVING_MOREPACKETSVEHICLE = MOVING + "morepacketsvehicle.";
|
private static final String MOVING_MOREPACKETSVEHICLE = MOVING + "morepacketsvehicle.";
|
||||||
|
@ -357,6 +357,8 @@ public class DefaultConfig extends ConfigFile {
|
|||||||
set(ConfPaths.MOVING_MOREPACKETS_CHECK, true);
|
set(ConfPaths.MOVING_MOREPACKETS_CHECK, true);
|
||||||
set(ConfPaths.MOVING_MOREPACKETS_EPSIDEAL, 20);
|
set(ConfPaths.MOVING_MOREPACKETS_EPSIDEAL, 20);
|
||||||
set(ConfPaths.MOVING_MOREPACKETS_EPSMAX, 22);
|
set(ConfPaths.MOVING_MOREPACKETS_EPSMAX, 22);
|
||||||
|
set(ConfPaths.MOVING_MOREPACKETS_BURST_PACKETS, 40);
|
||||||
|
set(ConfPaths.MOVING_MOREPACKETS_BURST_EPM, 30);
|
||||||
set(ConfPaths.MOVING_MOREPACKETS_ACTIONS, "cancel vl>10 log:morepackets:0:2:if cancel vl>100 log:morepackets:0:2:if cancel cmd:kickpackets");
|
set(ConfPaths.MOVING_MOREPACKETS_ACTIONS, "cancel vl>10 log:morepackets:0:2:if cancel vl>100 log:morepackets:0:2:if cancel cmd:kickpackets");
|
||||||
|
|
||||||
set(ConfPaths.MOVING_MOREPACKETSVEHICLE_CHECK, true);
|
set(ConfPaths.MOVING_MOREPACKETSVEHICLE_CHECK, true);
|
||||||
|
@ -30,9 +30,12 @@ public class NetStatic {
|
|||||||
* @param idealPackets
|
* @param idealPackets
|
||||||
* The "ideal" amount of packets per second. Used for "burning"
|
* The "ideal" amount of packets per second. Used for "burning"
|
||||||
* time frames by setting them to this amount.
|
* time frames by setting them to this amount.
|
||||||
* @return The violation amount, i.e. "count above limit".
|
* @param burstFreq Counting burst events, should be covering a minute or so.
|
||||||
|
* @param burstPackets Packets in the first time window to add to burst count.
|
||||||
|
* @param burstEPM Events per minute to trigger a burst violation.
|
||||||
|
* @return The violation amount, i.e. "count above limit", 0.0 if no violation.
|
||||||
*/
|
*/
|
||||||
public static double morePacketsCheck(final ActionFrequency packetFreq, final long time, final float packets, final float maxPackets, final float idealPackets) {
|
public static double morePacketsCheck(final ActionFrequency packetFreq, final long time, final float packets, final float maxPackets, final float idealPackets, final ActionFrequency burstFreq, final float burstPackets, final double burstEPM) {
|
||||||
// Pull down stuff.
|
// Pull down stuff.
|
||||||
final long winDur = packetFreq.bucketDuration();
|
final long winDur = packetFreq.bucketDuration();
|
||||||
final int winNum = packetFreq.numberOfBuckets();
|
final int winNum = packetFreq.numberOfBuckets();
|
||||||
@ -75,7 +78,7 @@ public class NetStatic {
|
|||||||
final double fullCount;
|
final double fullCount;
|
||||||
if (burnStart < winNum) {
|
if (burnStart < winNum) {
|
||||||
// Assume all following time windows are burnt.
|
// Assume all following time windows are burnt.
|
||||||
// TODO: empty score + trailing score !? max with trailing bukkets * ideal (!)
|
// TODO: empty score + trailing score !? max with trailing buckets * ideal (!)
|
||||||
final float trailing = Math.max(packetFreq.trailingScore(burnStart, 1f), burnScore * (winNum - burnStart - empty));
|
final float trailing = Math.max(packetFreq.trailingScore(burnStart, 1f), burnScore * (winNum - burnStart - empty));
|
||||||
final float leading = packetFreq.leadingScore(burnStart, 1f);
|
final float leading = packetFreq.leadingScore(burnStart, 1f);
|
||||||
fullCount = leading + trailing;
|
fullCount = leading + trailing;
|
||||||
@ -84,8 +87,13 @@ public class NetStatic {
|
|||||||
fullCount = packetFreq.score(1f);
|
fullCount = packetFreq.score(1f);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (double) fullCount - (double) (maxPackets * winNum * winDur / 1000f);
|
double violation = (double) fullCount - (double) (maxPackets * winNum * winDur / 1000f);
|
||||||
|
final float burst = packetFreq.bucketScore(0);
|
||||||
|
if (burst > burstPackets) {
|
||||||
|
burstFreq.add(time, 1f); // TODO: Remove float packets or do this properly.
|
||||||
|
violation = Math.max(violation, burstEPM * (double) (burstFreq.bucketDuration() * burstFreq.numberOfBuckets()) / 60000.0 - (double) burstFreq.score(0f));
|
||||||
|
}
|
||||||
|
return Math.max(0.0, violation);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user