Remove the strapackets cancel part, only skip FlyingFrequency on ACK.

This commit is contained in:
asofold 2015-12-06 23:53:22 +01:00
parent 067d6298d9
commit 4d3ee38881
6 changed files with 25 additions and 27 deletions

View File

@ -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;
}

View File

@ -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) {

View File

@ -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()));

View File

@ -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".

View File

@ -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";
}

View File

@ -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<String>());
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();