Class RejectionLog

java.lang.Object
org.tentackle.trip.RejectionLog

public final class RejectionLog extends Object
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

    Fields
    Modifier and Type
    Field
    Description
    static final long
    Default interval in milliseconds.
    static final int
    Default maximum number of messages per interval.
  • Method Summary

    Modifier and Type
    Method
    Description
    static long
    Gets the interval.
    static int
    Gets the maximum number of messages logged per interval.
    static boolean
    Returns whether the next message about an unauthenticated peer may be logged.
    Counts the message as logged if so, as suppressed otherwise.
    static void
    setInterval(long interval)
    Sets the interval.
    static void
    setMaxMessages(int maxMessages)
    Sets the maximum number of messages logged per interval.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • DEFAULT_MAX_MESSAGES

      public static final int DEFAULT_MAX_MESSAGES
      Default maximum number of messages per interval.
      See Also:
    • DEFAULT_INTERVAL

      public static final long DEFAULT_INTERVAL
      Default 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