Class EndpointConfig.Builder

java.lang.Object
io.github.mahmoudimus.quic.connection.EndpointConfig.Builder
Enclosing class:
EndpointConfig

public static final class EndpointConfig.Builder extends Object
Builds an EndpointConfig. Not thread-safe.
  • Method Details

    • random

      public EndpointConfig.Builder random(SecureRandom random)
      The source of randomness for the endpoint and its connections: connection IDs (unless a cidGenerator is set), the reset key (unless one is set), packet number skipping, padding, Retry and NEW_TOKEN nonces. By default each endpoint makes a SecureRandom of its own; a seeded one makes test runs reproducible, and must never be used outside tests.
      Parameters:
      random - the source, used from the endpoint's thread
      Returns:
      this builder
    • cidGenerator

      public EndpointConfig.Builder cidGenerator(ConnectionIdGenerator generator)
      The local connection ID generator. Its length is fixed for the endpoint; a length of 0 routes packets by the peer's address instead (zero-length connection IDs).
      Parameters:
      generator - the generator; must be thread-safe
      Returns:
      this builder
    • cidLength

      public EndpointConfig.Builder cidLength(int length)
      Random local connection IDs of a length.
      Parameters:
      length - 0 to 20 bytes
      Returns:
      this builder
    • resetKey

      public EndpointConfig.Builder resetKey(byte[] key)
      The secret stateless reset tokens are derived from. Endpoints that should be able to reset each other's connections after a restart share it.
      Parameters:
      key - at least 32 bytes
      Returns:
      this builder
    • supportedVersions

      public EndpointConfig.Builder supportedVersions(QuicVersion... versions)
      The QUIC versions to accept. A server answers others with Version Negotiation.
      Parameters:
      versions - one or more versions, in preference order
      Returns:
      this builder
    • minResetInterval

      public EndpointConfig.Builder minResetInterval(Duration interval)
      The least time between two stateless resets, which bounds what spoofed packets can make the endpoint send.
      Parameters:
      interval - the interval
      Returns:
      this builder
    • build

      public EndpointConfig build()
      Builds the configuration.
      Returns:
      the configuration