log possible DoS attack

This commit is contained in:
woodser 2025-05-28 10:36:46 -04:00 committed by woodser
parent a37654e116
commit 5d5eb649c6
3 changed files with 5 additions and 5 deletions

View file

@ -656,7 +656,7 @@ public class Connection implements HasCapabilities, Runnable, MessageListener {
private static synchronized void resetReportedInvalidRequestsThrottle(boolean logReport) { private static synchronized void resetReportedInvalidRequestsThrottle(boolean logReport) {
if (logReport) { if (logReport) {
if (numThrottledInvalidRequestReports > 0) log.warn("We received {} other reports of invalid requests since the last log entry", numThrottledInvalidRequestReports); if (numThrottledInvalidRequestReports > 0) log.warn("Possible DoS attack detected. We received {} other reports of invalid requests since the last log entry", numThrottledInvalidRequestReports);
numThrottledInvalidRequestReports = 0; numThrottledInvalidRequestReports = 0;
lastLoggedInvalidRequestReportTs = System.currentTimeMillis(); lastLoggedInvalidRequestReportTs = System.currentTimeMillis();
} }
@ -942,7 +942,7 @@ public class Connection implements HasCapabilities, Runnable, MessageListener {
boolean doLog = System.currentTimeMillis() - lastLoggedWarningTs > LOG_THROTTLE_INTERVAL_MS; boolean doLog = System.currentTimeMillis() - lastLoggedWarningTs > LOG_THROTTLE_INTERVAL_MS;
if (doLog) { if (doLog) {
log.warn(msg); log.warn(msg);
if (numThrottledWarnings > 0) log.warn("{} warnings were throttled since the last log entry", numThrottledWarnings); if (numThrottledWarnings > 0) log.warn("Possible DoS attack detected. {} warnings were throttled since the last log entry", numThrottledWarnings);
numThrottledWarnings = 0; numThrottledWarnings = 0;
lastLoggedWarningTs = System.currentTimeMillis(); lastLoggedWarningTs = System.currentTimeMillis();
} else { } else {
@ -954,7 +954,7 @@ public class Connection implements HasCapabilities, Runnable, MessageListener {
boolean doLog = System.currentTimeMillis() - lastLoggedInfoTs > LOG_THROTTLE_INTERVAL_MS; boolean doLog = System.currentTimeMillis() - lastLoggedInfoTs > LOG_THROTTLE_INTERVAL_MS;
if (doLog) { if (doLog) {
log.info(msg); log.info(msg);
if (numThrottledInfos > 0) log.info("{} info logs were throttled since the last log entry", numThrottledInfos); if (numThrottledInfos > 0) log.info("Possible DoS attack detected. {} info logs were throttled since the last log entry", numThrottledInfos);
numThrottledInfos = 0; numThrottledInfos = 0;
lastLoggedInfoTs = System.currentTimeMillis(); lastLoggedInfoTs = System.currentTimeMillis();
} else { } else {

View file

@ -173,7 +173,7 @@ class KeepAliveHandler implements MessageListener {
boolean logWarning = System.currentTimeMillis() - lastLoggedWarningTs > LOG_THROTTLE_INTERVAL_MS; boolean logWarning = System.currentTimeMillis() - lastLoggedWarningTs > LOG_THROTTLE_INTERVAL_MS;
if (logWarning) { if (logWarning) {
log.warn(msg); log.warn(msg);
if (numThrottledWarnings > 0) log.warn("{} warnings were throttled since the last log entry", numThrottledWarnings); if (numThrottledWarnings > 0) log.warn("Possible DoS attack detected. {} warnings were throttled since the last log entry", numThrottledWarnings);
numThrottledWarnings = 0; numThrottledWarnings = 0;
lastLoggedWarningTs = System.currentTimeMillis(); lastLoggedWarningTs = System.currentTimeMillis();
} else { } else {

View file

@ -222,7 +222,7 @@ class PeerExchangeHandler implements MessageListener {
boolean logWarning = System.currentTimeMillis() - lastLoggedWarningTs > LOG_THROTTLE_INTERVAL_MS; boolean logWarning = System.currentTimeMillis() - lastLoggedWarningTs > LOG_THROTTLE_INTERVAL_MS;
if (logWarning) { if (logWarning) {
log.warn(msg); log.warn(msg);
if (numThrottledWarnings > 0) log.warn("{} warnings were throttled since the last log entry", numThrottledWarnings); if (numThrottledWarnings > 0) log.warn("Possible DoS attack detected. {} warnings were throttled since the last log entry", numThrottledWarnings);
numThrottledWarnings = 0; numThrottledWarnings = 0;
lastLoggedWarningTs = System.currentTimeMillis(); lastLoggedWarningTs = System.currentTimeMillis();
} else { } else {