Adjust noPwnageVL: use a queue that expires gradually with time instead

of one single VL entry. Blends in nice with globalchat, if captcha is
off and ban actions removed (nopwnage just kicks then).
This commit is contained in:
asofold 2012-09-01 20:57:47 +02:00
parent e0c153da45
commit ca418d7887
4 changed files with 18 additions and 8 deletions

View File

@ -82,6 +82,7 @@ public class ChatConfig implements CheckConfig {
public final boolean noPwnageCheck;
public final List<String> noPwnageExclusions;
public final int noPwnageLevel;
public final float noPwnageVLFactor;
public final boolean noPwnageBannedCheck;
public final long noPwnageBannedTimeout;
@ -161,6 +162,8 @@ public class ChatConfig implements CheckConfig {
noPwnageCheck = data.getBoolean(ConfPaths.CHAT_NOPWNAGE_CHECK);
noPwnageExclusions = data.getStringList(ConfPaths.CHAT_NOPWNAGE_EXCLUSIONS);
noPwnageLevel = data.getInt(ConfPaths.CHAT_NOPWNAGE_LEVEL);
// VL decreasing factor, hidden option.
noPwnageVLFactor = (float) data.getDouble(ConfPaths.CHAT_NOPWNAGE_VL_FACTOR, 0.95);
noPwnageBannedCheck = data.getBoolean(ConfPaths.CHAT_NOPWNAGE_BANNED_CHECK);
noPwnageBannedTimeout = data.getLong(ConfPaths.CHAT_NOPWNAGE_BANNED_TIMEOUT);

View File

@ -51,7 +51,7 @@ public class ChatData implements CheckData {
public double captchaVL;
public double colorVL;
public double globalChatVL;
public double noPwnageVL;
public ActionFrequency noPwnageVL = new ActionFrequency(10, 3000);
// Data of the globalchat check.
public final ActionFrequency globalChatFrequency = new ActionFrequency(10, 3000);
@ -75,7 +75,8 @@ public class ChatData implements CheckData {
public synchronized void clearNoPwnageData() {
noPwnageCaptchTries = noPwnageReloginWarnings = 0;
captchaVL = 0D;
// colorVL, noPwnageVL <- are spared to avoid problems with spam + captcha success.
// colorVL <- is spared to avoid problems with spam + captcha success.
// noPwnageVL <- Is handled by the ActionFrequency forgtting mechanism, currently (call clear otherwise).
noPwnageJoinTime = noPwnageLastMessageTime = noPwnageLastMovedTime = noPwnageLastWarningTime = noPwnageLeaveTime = noPwnageReloginWarningTime = 0L;
noPwnageGeneratedCaptcha = noPwnageLastMessage = "";
}

View File

@ -134,6 +134,9 @@ public class NoPwnage extends Check implements ICaptcha{
return false;
final long now = System.currentTimeMillis();
// Forget expired VL.
data.noPwnageVL.update(now);
if (shouldCheckCaptcha(cc, data)) {
checkCaptcha(player, message, cc, data, isMainThread);
@ -198,15 +201,15 @@ public class NoPwnage extends Check implements ICaptcha{
player.getName())));
// Increment the violation level.
data.noPwnageVL += suspicion / 10D;
data.noPwnageVL.add(now, (float) (suspicion / 10D));
// Find out if we need to kick the player or not.
cancel = executeActionsThreadSafe(player, data.noPwnageVL, suspicion / 10D, cc.noPwnageActions,
cancel = executeActionsThreadSafe(player, cc.noPwnageVLFactor, suspicion / 10D, cc.noPwnageActions,
isMainThread);
}
else
// Reduce the violation level.
data.noPwnageVL *= 0.95D;
// else
// // Reduce the violation level. <- Done automatically by queue.
// data.noPwnageVL *= 0.95D;
// Store the message and some other data.
data.noPwnageLastMessage = message;
@ -300,7 +303,7 @@ public class NoPwnage extends Check implements ICaptcha{
data.noPwnageReloginWarnings++;
} else if (now - data.noPwnageReloginWarningTime < cc.noPwnageReloginWarningTimeout)
// Find out if we need to ban the player or not.
cancel = executeActionsThreadSafe(player, data.noPwnageVL, data.noPwnageVL, cc.noPwnageActions, true);
cancel = executeActionsThreadSafe(player, (double) data.noPwnageVL.getScore(cc.noPwnageVLFactor), 0D, cc.noPwnageActions, true);
}
// Store his joining time.

View File

@ -201,6 +201,9 @@ public abstract class ConfPaths {
public static final String CHAT_NOPWNAGE_SPEED_CHECK = CHAT_NOPWNAGE_SPEED + "active";
public static final String CHAT_NOPWNAGE_SPEED_TIMEOUT = CHAT_NOPWNAGE_SPEED + "timeout";
public static final String CHAT_NOPWNAGE_SPEED_WEIGHT = CHAT_NOPWNAGE_SPEED + "weight";
public static final String CHAT_NOPWNAGE_VL = CHAT_NOPWNAGE + "vl.";
public static final String CHAT_NOPWNAGE_VL_FACTOR = CHAT_NOPWNAGE_VL + "factor";
private static final String CHAT_NOPWNAGE_WARN = CHAT_NOPWNAGE + "warn.";
public static final String CHAT_NOPWNAGE_WARN_LEVEL = CHAT_NOPWNAGE_WARN + "level";