From 4d3ee38881ca959b5e52fa0b7cf8aaefbcbce0ed Mon Sep 17 00:00:00 2001 From: asofold Date: Sun, 6 Dec 2015 23:53:22 +0100 Subject: [PATCH] Remove the strapackets cancel part, only skip FlyingFrequency on ACK. --- .../checks/net/protocollib/MovingFlying.java | 36 +++++++++---------- .../net/protocollib/OutgoingPosition.java | 2 +- .../net/protocollib/ProtocolLibComponent.java | 2 +- .../nocheatplus/checks/net/NetConfig.java | 2 -- .../nocheatplus/config/ConfPaths.java | 7 ++-- .../nocheatplus/config/DefaultConfig.java | 3 +- 6 files changed, 25 insertions(+), 27 deletions(-) diff --git a/NCPCompatProtocolLib/src/main/java/fr/neatmonster/nocheatplus/checks/net/protocollib/MovingFlying.java b/NCPCompatProtocolLib/src/main/java/fr/neatmonster/nocheatplus/checks/net/protocollib/MovingFlying.java index 9229b5e9..42cac39e 100644 --- a/NCPCompatProtocolLib/src/main/java/fr/neatmonster/nocheatplus/checks/net/protocollib/MovingFlying.java +++ b/NCPCompatProtocolLib/src/main/java/fr/neatmonster/nocheatplus/checks/net/protocollib/MovingFlying.java @@ -99,6 +99,7 @@ public class MovingFlying extends BaseAdapter { final DataPacketFlying packetData = packetMismatch ? null : interpretPacket(event, time); // Early return tests, if the packet can be interpreted. + boolean skipFlyingFrequency = false; if (packetData != null) { // Prevent processing packets with obviously malicious content. if (isInvalidContent(packetData)) { @@ -109,27 +110,22 @@ public class MovingFlying extends BaseAdapter { } return; } - if (cc.flyingFrequencyStrayPacketsCancel) { - switch(data.teleportQueue.processAck(packetData)) { - case CANCEL: { - // TODO: Configuration for cancel (or implement skipping violation level escalation)? - // TODO: Checking FlyingFrequency might still make sense? - event.setCancelled(true); - if (data.debug) { - NCPAPIProvider.getNoCheatPlusAPI().getLogManager().debug(Streams.TRACE_FILE, player.getName() + " wait for ACK on teleport, cancel packet: " + packetData); - } - return; + switch(data.teleportQueue.processAck(packetData)) { + case CANCEL: { + if (data.debug) { + NCPAPIProvider.getNoCheatPlusAPI().getLogManager().debug(Streams.TRACE_FILE, player.getName() + " incoming packet before having received ACK on outgoing position."); } - case ACK: { - // Skip processing ACK packets, no cancel. - if (data.debug) { - NCPAPIProvider.getNoCheatPlusAPI().getLogManager().debug(Streams.TRACE_FILE, player.getName() + " interpret as ACK for a teleport: " + packetData); - } - return; - } - default: { - // Continue. + } + case ACK: { + // Skip processing ACK packets, no cancel. + skipFlyingFrequency = true; + if (data.debug) { + NCPAPIProvider.getNoCheatPlusAPI().getLogManager().debug(Streams.TRACE_FILE, player.getName() + " incoming packet interpreted as ACK for outgoing position."); } + return; + } + default: { + // Continue. } } } @@ -138,7 +134,7 @@ public class MovingFlying extends BaseAdapter { // Actual packet frequency check. // TODO: Consider using the NetStatic check. - if (flyingFrequency.check(player, packetData, time, data, cc)) { + if (!skipFlyingFrequency && flyingFrequency.check(player, packetData, time, data, cc)) { event.setCancelled(true); return; } diff --git a/NCPCompatProtocolLib/src/main/java/fr/neatmonster/nocheatplus/checks/net/protocollib/OutgoingPosition.java b/NCPCompatProtocolLib/src/main/java/fr/neatmonster/nocheatplus/checks/net/protocollib/OutgoingPosition.java index f414cb56..6f2992d4 100644 --- a/NCPCompatProtocolLib/src/main/java/fr/neatmonster/nocheatplus/checks/net/protocollib/OutgoingPosition.java +++ b/NCPCompatProtocolLib/src/main/java/fr/neatmonster/nocheatplus/checks/net/protocollib/OutgoingPosition.java @@ -40,7 +40,7 @@ public class OutgoingPosition extends BaseAdapter { final Player player = event.getPlayer(); final NetConfig cc = configFactory.getConfig(player); - if (cc.flyingFrequencyActive && cc.flyingFrequencyStrayPacketsCancel) { + if (cc.flyingFrequencyActive) { final NetData data = dataFactory.getData(player); final DataPacketFlying packetData = interpretPacket(event.getPacket(), time, data); if (packetData != null && data.debug) { diff --git a/NCPCompatProtocolLib/src/main/java/fr/neatmonster/nocheatplus/checks/net/protocollib/ProtocolLibComponent.java b/NCPCompatProtocolLib/src/main/java/fr/neatmonster/nocheatplus/checks/net/protocollib/ProtocolLibComponent.java index 9a721b07..2f345f32 100644 --- a/NCPCompatProtocolLib/src/main/java/fr/neatmonster/nocheatplus/checks/net/protocollib/ProtocolLibComponent.java +++ b/NCPCompatProtocolLib/src/main/java/fr/neatmonster/nocheatplus/checks/net/protocollib/ProtocolLibComponent.java @@ -182,7 +182,7 @@ public class ProtocolLibComponent implements DisableListener, INotifyReload, Joi } final Player player = event.getPlayer(); final NetConfig cc = configFactory.getConfig(player); - if (cc.flyingFrequencyActive && cc.flyingFrequencyStrayPacketsCancel) { + if (cc.flyingFrequencyActive) { final NetData data = dataFactory.getData(player); // Register expected location for comparison with outgoing packets. data.teleportQueue.onTeleportEvent(new DataPacketFlying(false, to.getX(), to.getY(), to.getZ(), to.getYaw(), to.getPitch(), System.currentTimeMillis())); diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/net/NetConfig.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/net/NetConfig.java index 22885191..d4f3707d 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/net/NetConfig.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/net/NetConfig.java @@ -27,7 +27,6 @@ public class NetConfig extends ACheckConfig { public final int flyingFrequencySeconds; public final double flyingFrequencyPPS; public final ActionList flyingFrequencyActions; - public final boolean flyingFrequencyStrayPacketsCancel; public final boolean flyingFrequencyRedundantActive; public final int flyingFrequencyRedundantSeconds; public final ActionList flyingFrequencyRedundantActions; @@ -60,7 +59,6 @@ public class NetConfig extends ACheckConfig { flyingFrequencySeconds = Math.max(1, globalConfig.getInt(ConfPaths.NET_FLYINGFREQUENCY_SECONDS)); flyingFrequencyPPS = Math.max(1.0, globalConfig.getDouble(ConfPaths.NET_FLYINGFREQUENCY_PACKETSPERSECOND)); flyingFrequencyActions = config.getOptimizedActionList(ConfPaths.NET_FLYINGFREQUENCY_ACTIONS, Permissions.NET_FLYINGFREQUENCY); - flyingFrequencyStrayPacketsCancel = config.getBoolean(ConfPaths.NET_FLYINGFREQUENCY_STRAYPACKETS_CANCEL); flyingFrequencyRedundantActive = config.getBoolean(ConfPaths.NET_FLYINGFREQUENCY_CANCELREDUNDANT); flyingFrequencyRedundantSeconds = Math.max(1, config.getInt(ConfPaths.NET_FLYINGFREQUENCY_REDUNDANT_SECONDS)); // Same permission for "silent". diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/config/ConfPaths.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/config/ConfPaths.java index 3e1a6c0c..c3708678 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/config/ConfPaths.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/config/ConfPaths.java @@ -631,8 +631,6 @@ public abstract class ConfPaths { @GlobalConfig public static final String NET_FLYINGFREQUENCY_PACKETSPERSECOND = NET_FLYINGFREQUENCY + "packetspersecond"; public static final String NET_FLYINGFREQUENCY_ACTIONS = NET_FLYINGFREQUENCY + "actions"; - public static final String NET_FLYINGFREQUENCY_STRAYPACKETS = NET_FLYINGFREQUENCY + "straypackets."; - public static final String NET_FLYINGFREQUENCY_STRAYPACKETS_CANCEL = NET_FLYINGFREQUENCY_STRAYPACKETS + "cancel"; // TODO: Reduceredundant has been removed (implement or remove config). private static final String NET_FLYINGFREQUENCY_REDUNDANT = NET_FLYINGFREQUENCY + "reduceredundant."; public static final String NET_FLYINGFREQUENCY_REDUNDANT_ACTIVE = NET_FLYINGFREQUENCY_REDUNDANT + "active"; @@ -667,6 +665,9 @@ public abstract class ConfPaths { public static final String COMPATIBILITY_SERVER_CBREFLECT_ENABLE = COMPATIBILITY_SERVER_CBREFLECT + "enable"; public static final String COMPATIBILITY_BLOCKS = COMPATIBILITY + "blocks."; + public static final String COMPATIBILITY_BLOCKS_CHANGETRACKER = COMPATIBILITY_BLOCKS + "changetracker."; + public static final String COMPATIBILITY_BLOCKS_CHANGETRACKER_ACTIVE = COMPATIBILITY_BLOCKS_CHANGETRACKER + "active"; + public static final String COMPATIBILITY_BLOCKS_CHANGETRACKER_PISTONS= COMPATIBILITY_BLOCKS_CHANGETRACKER + "pistons"; // Moved paths. @Moved(newPath = LOGGING_BACKEND_CONSOLE_ACTIVE) @@ -732,5 +733,7 @@ public abstract class ConfPaths { public static final String LOGGING_BACKEND_CONSOLE_PREFIX = "logging.backend.console.prefix"; @Deprecated public static final String MOVING_VELOCITY_GRACETICKS = "checks.moving.velocity.graceticks"; + @Deprecated + public static final String NET_FLYINGFREQUENCY_STRAYPACKETS_CANCEL = "checks.net.flyingfrequency.straypackets.cancel"; } diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/config/DefaultConfig.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/config/DefaultConfig.java index a61e2d61..e741887f 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/config/DefaultConfig.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/config/DefaultConfig.java @@ -445,7 +445,6 @@ public class DefaultConfig extends ConfigFile { set(ConfPaths.NET_FLYINGFREQUENCY_SECONDS, 5); set(ConfPaths.NET_FLYINGFREQUENCY_PACKETSPERSECOND, 60); set(ConfPaths.NET_FLYINGFREQUENCY_ACTIONS, "cancel"); // TODO: Log actions. - set(ConfPaths.NET_FLYINGFREQUENCY_STRAYPACKETS_CANCEL, true); set(ConfPaths.NET_FLYINGFREQUENCY_REDUNDANT_ACTIVE, true); set(ConfPaths.NET_FLYINGFREQUENCY_REDUNDANT_SECONDS, 3); set(ConfPaths.NET_FLYINGFREQUENCY_REDUNDANT_ACTIONS, "cancel"); // TODO: Log actions. @@ -546,6 +545,8 @@ public class DefaultConfig extends ConfigFile { )); set(ConfPaths.COMPATIBILITY_BLOCKS + ConfPaths.SUB_ALLOWINSTANTBREAK, new LinkedList()); set(ConfPaths.COMPATIBILITY_BLOCKS + ConfPaths.SUB_OVERRIDEFLAGS + ".snow", "default"); + set(ConfPaths.COMPATIBILITY_BLOCKS_CHANGETRACKER_ACTIVE, true); + set(ConfPaths.COMPATIBILITY_BLOCKS_CHANGETRACKER_PISTONS, true); // // Update internal factory based on all the new entries to the "actions" section. // setActionFactory();