Fix burstEPM violation + add tags for MorePackets + more lenient burst.

This commit is contained in:
asofold 2014-07-26 21:38:29 +02:00
parent 901b2a45a2
commit 564ce88132
3 changed files with 37 additions and 13 deletions

View File

@ -1,5 +1,8 @@
package fr.neatmonster.nocheatplus.checks.moving; package fr.neatmonster.nocheatplus.checks.moving;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -9,6 +12,7 @@ import fr.neatmonster.nocheatplus.checks.CheckType;
import fr.neatmonster.nocheatplus.checks.ViolationData; import fr.neatmonster.nocheatplus.checks.ViolationData;
import fr.neatmonster.nocheatplus.net.NetStatic; import fr.neatmonster.nocheatplus.net.NetStatic;
import fr.neatmonster.nocheatplus.utilities.PlayerLocation; import fr.neatmonster.nocheatplus.utilities.PlayerLocation;
import fr.neatmonster.nocheatplus.utilities.StringUtil;
/** /**
* The MorePackets check will try to identify players that send more than the usual * The MorePackets check will try to identify players that send more than the usual
@ -17,6 +21,8 @@ import fr.neatmonster.nocheatplus.utilities.PlayerLocation;
*/ */
public class MorePackets extends Check { public class MorePackets extends Check {
private final List<String> tags = new ArrayList<String>();
/** /**
* Instantiates a new more packets check. * Instantiates a new more packets check.
*/ */
@ -60,7 +66,8 @@ 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, data.morePacketsBurstFreq, cc.morePacketsBurstPackets, cc.morePacketsBurstDirect, cc.morePacketsBurstEPM); tags.clear();
final double violation = NetStatic.morePacketsCheck(data.morePacketsFreq, time, 1f, cc.morePacketsEPSMax, cc.morePacketsEPSIdeal, data.morePacketsBurstFreq, cc.morePacketsBurstPackets, cc.morePacketsBurstDirect, cc.morePacketsBurstEPM, tags);
// Process violation result. // Process violation result.
if (violation > 0.0) { if (violation > 0.0) {
@ -72,6 +79,7 @@ public class MorePackets extends Check {
final ViolationData vd = new ViolationData(this, player, data.morePacketsVL, violation, cc.morePacketsActions); final ViolationData vd = new ViolationData(this, player, data.morePacketsVL, violation, cc.morePacketsActions);
if (cc.debug || vd.needsParameters()) { if (cc.debug || vd.needsParameters()) {
vd.setParameter(ParameterName.PACKETS, Integer.toString(new Double(violation).intValue())); vd.setParameter(ParameterName.PACKETS, Integer.toString(new Double(violation).intValue()));
vd.setParameter(ParameterName.TAGS, StringUtil.join(tags, "+"));
} }
if (executeActions(vd)) { if (executeActions(vd)) {
// Set to cancel the move. // Set to cancel the move.

View File

@ -16,7 +16,7 @@ public class DefaultConfig extends ConfigFile {
* NCP build needed for this config. * NCP build needed for this config.
* (Should only increment with changing or removing paths.) * (Should only increment with changing or removing paths.)
*/ */
public static final int buildNumber = 695; public static final int buildNumber = 727;
// TODO: auto input full version or null to an extra variable or several [fail safe for other syntax checking]? // TODO: auto input full version or null to an extra variable or several [fail safe for other syntax checking]?
@ -358,8 +358,8 @@ public class DefaultConfig extends ConfigFile {
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_PACKETS, 40);
set(ConfPaths.MOVING_MOREPACKETS_BURST_DIRECT, 30); set(ConfPaths.MOVING_MOREPACKETS_BURST_DIRECT, 60);
set(ConfPaths.MOVING_MOREPACKETS_BURST_EPM, 120); set(ConfPaths.MOVING_MOREPACKETS_BURST_EPM, 180);
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);
@ -479,7 +479,7 @@ public class DefaultConfig extends ConfigFile {
set(ConfPaths.STRINGS + ".kickselfhit", "ncp kick [player] You tried to hit yourself!"); set(ConfPaths.STRINGS + ".kickselfhit", "ncp kick [player] You tried to hit yourself!");
set(ConfPaths.STRINGS + ".kickwb", "ncp kick [player] Block breaking out of sync!"); set(ConfPaths.STRINGS + ".kickwb", "ncp kick [player] Block breaking out of sync!");
set(ConfPaths.STRINGS + ".knockback", start + "tried to do a knockback but wasn't technically sprinting" + end); set(ConfPaths.STRINGS + ".knockback", start + "tried to do a knockback but wasn't technically sprinting" + end);
set(ConfPaths.STRINGS + ".morepackets", start + "sent [packets] more packet(s) than expected" + end); set(ConfPaths.STRINGS + ".morepackets", start + "sent too many moves ([packets] [tags])" + end);
set(ConfPaths.STRINGS + ".munchhausen", start + "almost made it off the pit" + end); set(ConfPaths.STRINGS + ".munchhausen", start + "almost made it off the pit" + end);
set(ConfPaths.STRINGS + ".nofall", start + "tried to avoid fall damage" + end); set(ConfPaths.STRINGS + ".nofall", start + "tried to avoid fall damage" + end);
set(ConfPaths.STRINGS + ".chatfast", start + "acted like spamming (IP: [ip])" + end); set(ConfPaths.STRINGS + ".chatfast", start + "acted like spamming (IP: [ip])" + end);

View File

@ -1,5 +1,7 @@
package fr.neatmonster.nocheatplus.net; package fr.neatmonster.nocheatplus.net;
import java.util.List;
import fr.neatmonster.nocheatplus.utilities.ActionFrequency; import fr.neatmonster.nocheatplus.utilities.ActionFrequency;
import fr.neatmonster.nocheatplus.utilities.TickTask; import fr.neatmonster.nocheatplus.utilities.TickTask;
@ -33,9 +35,10 @@ public class NetStatic {
* @param burstFreq Counting burst events, should be covering a minute or so. * @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 burstPackets Packets in the first time window to add to burst count.
* @param burstEPM Events per minute to trigger a burst violation. * @param burstEPM Events per minute to trigger a burst violation.
* @param tags List to add tags to, for which parts of this check triggered a violation.
* @return The violation amount, i.e. "count above limit", 0.0 if no 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, final ActionFrequency burstFreq, final float burstPackets, final double burstDirect, final double burstEPM) { 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 burstDirect, final double burstEPM, final List<String> tags) {
// 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();
@ -87,16 +90,29 @@ public class NetStatic {
fullCount = packetFreq.score(1f); fullCount = packetFreq.score(1f);
} }
double violation = (double) fullCount - (double) (maxPackets * winNum * winDur / 1000f); double violation = 0.0; // Classic processing.
final float burst = packetFreq.bucketScore(0); final double vEPSAcc = (double) fullCount - (double) (maxPackets * winNum * winDur / 1000f);
if (vEPSAcc > 0.0) {
violation = Math.max(violation, vEPSAcc);
tags.add("epsacc");
}
float burst = packetFreq.bucketScore(0);
if (burst > burstPackets) { if (burst > burstPackets) {
// Account for server-side lag "minimally". // Account for server-side lag "minimally".
if (burst > burstPackets * TickTask.getLag(winDur, true)) { burst /= TickTask.getLag(winDur, true);
// TODO: Does lag adaption suffice this way ? if (burst > burstPackets) {
final double vBurstDirect = burst - burstDirect;
if (vBurstDirect > 0.0) {
violation = Math.max(violation, vBurstDirect);
tags.add("burstdirect");
}
// TODO: Lag adaption for the burstFreq too [differing window durations]?
burstFreq.add(time, 1f); // TODO: Remove float packets or do this properly. burstFreq.add(time, 1f); // TODO: Remove float packets or do this properly.
violation = Math.max(violation, burst - burstDirect); final double vBurstEPM = (double) burstFreq.score(0f) - burstEPM * (double) (burstFreq.bucketDuration() * burstFreq.numberOfBuckets()) / 60000.0;
violation = Math.max(violation, burstEPM * (double) (burstFreq.bucketDuration() * burstFreq.numberOfBuckets()) / 60000.0 - (double) burstFreq.score(0f)); if (vBurstEPM > 0.0) {
violation = Math.max(violation, vBurstEPM);
tags.add("burstepm");
}
} }
} }
return Math.max(0.0, violation); return Math.max(0.0, violation);