Class RejectionLog
java.lang.Object
org.tentackle.trip.RejectionLog
Throttles the log messages about peers that are not authenticated.
Every rejected connection is logged: an invalid magic, a broken handshake, a policy violation, an evicted
or refused connection. Anybody who can reach the port can open connections as fast as the network allows,
so these messages could fill the disk. Within each interval, at most
maxMessages are logged. The first message of the next interval is preceded
by a summary of how many were suppressed.
The limit is global, not per host: an attacker with many addresses would otherwise multiply it.
if (RejectionLog.isLoggable()) {
LOGGER.warning("connection {0} sent an invalid magic -> closed", clientInfo);
}
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longDefault interval in milliseconds.static final intDefault maximum number of messages per interval. -
Method Summary
Modifier and TypeMethodDescriptionstatic longGets the interval.static intGets the maximum number of messages logged per interval.static booleanReturns whether the next message about an unauthenticated peer may be logged.
Counts the message as logged if so, as suppressed otherwise.static voidsetInterval(long interval) Sets the interval.static voidsetMaxMessages(int maxMessages) Sets the maximum number of messages logged per interval.
-
Field Details
-
DEFAULT_MAX_MESSAGES
public static final int DEFAULT_MAX_MESSAGESDefault maximum number of messages per interval.- See Also:
-
DEFAULT_INTERVAL
public static final long DEFAULT_INTERVALDefault interval in milliseconds.- See Also:
-
-
Method Details
-
isLoggable
public static boolean isLoggable()Returns whether the next message about an unauthenticated peer may be logged.
Counts the message as logged if so, as suppressed otherwise.- Returns:
- true if the message may be logged
-
setMaxMessages
public static void setMaxMessages(int maxMessages) Sets the maximum number of messages logged per interval.- Parameters:
maxMessages- the maximum number, 0 to log all
-
getMaxMessages
public static int getMaxMessages()Gets the maximum number of messages logged per interval.- Returns:
- the maximum number, 0 if all are logged
-
setInterval
public static void setInterval(long interval) Sets the interval.- Parameters:
interval- the interval in milliseconds, 0 to log all
-
getInterval
public static long getInterval()Gets the interval.- Returns:
- the interval in milliseconds
-