Interface ConnectionIdGenerator

All Known Implementing Classes:
RandomConnectionIdGenerator

public interface ConnectionIdGenerator
Generates the connection IDs an endpoint issues. IDs must not let an observer link them to other IDs of the same connection (RFC 9000 section 5.1): they need high entropy, from cryptographic randomness or encryption.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    The length of the IDs, which the endpoint needs to parse short headers.
    long
    How long an ID lives before it is retired and replaced.
    A new connection ID.
    default boolean
    Whether an ID could have come from this generator, to drop stray packets cheaply.
  • Method Details

    • generateCid

      ConnectionId generateCid()
      A new connection ID.
      Returns:
      an ID of cidLength() bytes
    • validate

      default boolean validate(ConnectionId cid)
      Whether an ID could have come from this generator, to drop stray packets cheaply. False positives are allowed.
      Parameters:
      cid - the ID
      Returns:
      true by default
    • cidLength

      int cidLength()
      The length of the IDs, which the endpoint needs to parse short headers.
      Returns:
      0 to 20 bytes
    • cidLifetime

      long cidLifetime()
      How long an ID lives before it is retired and replaced.
      Returns:
      nanoseconds, or -1 for forever