Class ServerConfig.Builder
java.lang.Object
io.github.mahmoudimus.quic.connection.ServerConfig.Builder
- Enclosing class:
ServerConfig
Builds a
ServerConfig. Not thread-safe.-
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds the configuration.clock(InstantSource clock) The wall clock token expiry is checked against.maxConnections(int max) The most connections held at once.migration(boolean migration) Whether clients may migrate (RFC 9000 section 9): on by default, as in quinn.newTokens(int count) How many NEW_TOKEN tokens to send each client after its handshake (RFC 9000 section 8.1.3).preferredAddress(InetSocketAddress ipv4, InetSocketAddress ipv6) Advertises a preferred address (RFC 9000 section 9.6) in thepreferred_addresstransport parameter, with a connection ID of its own: a client may validate it after the handshake and move there.retry(boolean retry) Turns Retry-based address validation on or off (off by default).retryTokenLifetime(Duration lifetime) How long a Retry token stays valid.The key Retry tokens are sealed with; servers behind one address share it.transport(TransportConfig transport) The transport settings.validationTokenLifetime(Duration lifetime) How long a NEW_TOKEN token stays valid.
-
Method Details
-
transport
The transport settings.- Parameters:
transport- the settings- Returns:
- this builder
-
retry
Turns Retry-based address validation on or off (off by default).- Parameters:
retry- whether to send Retry to clients without a valid token- Returns:
- this builder
-
tokenKey
The key Retry tokens are sealed with; servers behind one address share it.- Parameters:
key- the key, or null for a random one- Returns:
- this builder
-
retryTokenLifetime
How long a Retry token stays valid.- Parameters:
lifetime- the lifetime, 15 seconds by default- Returns:
- this builder
-
newTokens
How many NEW_TOKEN tokens to send each client after its handshake (RFC 9000 section 8.1.3). A client presents one in its next connection's first Initial, which validates its address so that Retry is skipped; each token is accepted once.- Parameters:
count- 0 to send none; 2 by default, as quinn sends- Returns:
- this builder
-
validationTokenLifetime
How long a NEW_TOKEN token stays valid.- Parameters:
lifetime- the lifetime, two weeks by default- Returns:
- this builder
-
migration
Whether clients may migrate (RFC 9000 section 9): on by default, as in quinn. A connection then follows a client to a new address once a non-probing packet arrives from it, validates the new path, and goes back to the old one if validation fails. Off, the server sendsdisable_active_migrationand drops packets from any address but the one the handshake used; a client may still move to the preferred address.- Parameters:
migration- whether to allow migration- Returns:
- this builder
-
preferredAddress
Advertises a preferred address (RFC 9000 section 9.6) in thepreferred_addresstransport parameter, with a connection ID of its own: a client may validate it after the handshake and move there. The server must receive datagrams at the address;QuicServerbinds a socket to each address given (port 0 takes an ephemeral port, which is then advertised).- Parameters:
ipv4- the IPv4 address, or nullipv6- the IPv6 address, or null- Returns:
- this builder
- Throws:
IllegalArgumentException- if an address is of the other family
-
maxConnections
The most connections held at once.- Parameters:
max- at least 1; 4096 by default- Returns:
- this builder
-
clock
The wall clock token expiry is checked against.- Parameters:
clock- the clock- Returns:
- this builder
-
build
Builds the configuration.- Returns:
- the configuration
-