Class RandomConnectionIdGenerator

java.lang.Object
io.github.mahmoudimus.quic.connection.RandomConnectionIdGenerator
All Implemented Interfaces:
ConnectionIdGenerator

public final class RandomConnectionIdGenerator extends Object implements ConnectionIdGenerator
Generates random connection IDs of a fixed length, 8 bytes by default.

Threads. Safe to share if the Random is (a SecureRandom is).

  • Field Details

    • DEFAULT_LENGTH

      public static final int DEFAULT_LENGTH
      The default ID length, 8 bytes.
      See Also:
  • Constructor Details

    • RandomConnectionIdGenerator

      public RandomConnectionIdGenerator()
      A generator of 8-byte IDs from a new SecureRandom, which never expire.
    • RandomConnectionIdGenerator

      public RandomConnectionIdGenerator(int length, long lifetime, Random random)
      A generator.
      Parameters:
      length - the ID length, 0 to 20
      lifetime - how long IDs live in nanoseconds, or -1 for forever
      random - the source of randomness; a SecureRandom outside tests
      Throws:
      IllegalArgumentException - if the length is out of range
  • Method Details