Skip to content

Commit

Permalink
Don't allow invalid max-transaction-time
Browse files Browse the repository at this point in the history
  • Loading branch information
SamB440 committed Sep 24, 2024
1 parent da1468e commit ba8c411
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/main/java/ac/grim/grimac/manager/ConfigManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import ac.grim.grimac.GrimAC;
import ac.grim.grimac.GrimAPI;
import ac.grim.grimac.utils.anticheat.LogUtil;
import ac.grim.grimac.utils.math.GrimMath;
import github.scarsz.configuralize.DynamicConfig;
import github.scarsz.configuralize.Language;
import lombok.Getter;
Expand Down Expand Up @@ -77,7 +78,15 @@ public void reload() {
} catch (Exception e) {
throw new RuntimeException("Failed to load config", e);
}
maxPingTransaction = config.getIntElse("max-transaction-time", 60);

final int configuredMaxTransactionTime = config.getIntElse("max-transaction-time", 60);
maxPingTransaction = (int) GrimMath.clamp(configuredMaxTransactionTime, 0, 180);
if (maxPingTransaction != configuredMaxTransactionTime) {
LogUtil.warn("Detected invalid max-transaction-time! This setting is clamped between 0 and 180 to prevent issues. " +
"Changed: " + configuredMaxTransactionTime + " -> " + maxPingTransaction);
LogUtil.warn("Attempting to disable or set this too high can result in memory usage issues.");
}

ignoredClientPatterns.clear();
for (String string : config.getStringList("client-brand.ignored-clients")) {
try {
Expand Down

0 comments on commit ba8c411

Please sign in to comment.