pub struct QuicServerBuilder<T> { /* private fields */ }
Expand description
The builder for the quic server.
Implementations§
Source§impl<T> QuicServerBuilder<T>
impl<T> QuicServerBuilder<T>
Sourcepub fn with_supported_versions(
self,
versions: impl IntoIterator<Item = u32>,
) -> Self
pub fn with_supported_versions( self, versions: impl IntoIterator<Item = u32>, ) -> Self
(WIP)Specify the supported quic versions.
If you call this multiple times, only the last call will take effect.
Sourcepub fn with_token_provider(self, token_provider: Arc<dyn TokenProvider>) -> Self
pub fn with_token_provider(self, token_provider: Arc<dyn TokenProvider>) -> Self
Specify how server to create and verify the client’s Token in [address verification].
If you call this multiple times, only the last token_provider
will be used.
Sourcepub fn with_streams_concurrency_strategy(
self,
strategy_factory: impl ProductStreamsConcurrencyController + 'static,
) -> Self
pub fn with_streams_concurrency_strategy( self, strategy_factory: impl ProductStreamsConcurrencyController + 'static, ) -> Self
Specify the streams concurrency strategy controller for the server.
The streams controller is used to control the concurrency of data streams. controller
is a closure that accept
(initial maximum number of bidirectional streams, initial maximum number of unidirectional streams) configured in
[transport parameters] and return a ControlConcurrency
object.
If you call this multiple times, only the last controller
will be used.
Sourcepub fn defer_idle_timeout(self, config: HeartbeatConfig) -> Self
pub fn defer_idle_timeout(self, config: HeartbeatConfig) -> Self
Provide an option to defer an idle timeout.
This facility could be used when the application wishes to avoid losing state that has been associated with an open connection but does not expect to exchange application data for some time.
See Deferring Idle Timeout of RFC 9000 for more information.
Sourcepub fn with_parameters(self, parameters: ServerParameters) -> Self
pub fn with_parameters(self, parameters: ServerParameters) -> Self
Specify the [transport parameters] for the server.
If you call this multiple times, only the last parameters
will be used.
Usually, you don’t need to call this method, because the server will use a set of default parameters.
Sourcepub fn use_strict_mode(self) -> Self
pub fn use_strict_mode(self) -> Self
Accept connections from addresses that server not listened to.
§If the strict mode is not used (default)
QuicServer will not only accept connections from the address it is bound to, it will also accept connections
from all addresses that gm-quic is bound to (such as the address that QuicClient
is bound to).
For example, you started a client and connected to a remote server. If the strict mode is not used, the server can accept the connections that connected to the addresses that client used. This is useful in some cases, such as the server is behind a NAT.
§If the strict mode is used
The server will only accept connections from the given addresses that successfully bound.
Sourcepub fn with_iface_factory(
self,
factory: impl ProductQuicInterface + 'static,
) -> Self
pub fn with_iface_factory( self, factory: impl ProductQuicInterface + 'static, ) -> Self
Specify how QuicServerBuilder::listen
binds to the interface.
The default quic interface is UdpSocketController
that support GSO and GRO,
and the binder is UdpSocketController::bind
.
pub fn with_qlog(self, logger: Arc<dyn Log + Send + Sync>) -> Self
Source§impl QuicServerBuilder<ConfigBuilder<ServerConfig, WantsVerifier>>
impl QuicServerBuilder<ConfigBuilder<ServerConfig, WantsVerifier>>
Sourcepub fn with_client_cert_verifier(
self,
client_cert_verifier: Arc<dyn ClientCertVerifier>,
) -> QuicServerBuilder<ConfigBuilder<ServerConfig, WantsServerCert>>
pub fn with_client_cert_verifier( self, client_cert_verifier: Arc<dyn ClientCertVerifier>, ) -> QuicServerBuilder<ConfigBuilder<ServerConfig, WantsServerCert>>
Choose how to verify client certificates.
Sourcepub fn without_client_cert_verifier(
self,
) -> QuicServerBuilder<ConfigBuilder<ServerConfig, WantsServerCert>>
pub fn without_client_cert_verifier( self, ) -> QuicServerBuilder<ConfigBuilder<ServerConfig, WantsServerCert>>
Disable client authentication.
Source§impl QuicServerBuilder<ConfigBuilder<ServerConfig, WantsServerCert>>
impl QuicServerBuilder<ConfigBuilder<ServerConfig, WantsServerCert>>
Sourcepub fn with_single_cert(
self,
cert_chain: impl ToCertificate,
key_der: impl ToPrivateKey,
) -> QuicServerBuilder<TlsServerConfig>
pub fn with_single_cert( self, cert_chain: impl ToCertificate, key_der: impl ToPrivateKey, ) -> QuicServerBuilder<TlsServerConfig>
Sets a single certificate chain and matching private key. This certificate and key is used for all subsequent connections, irrespective of things like SNI hostname.
Read TlsServerConfigBuilder::with_single_cert
for more.
Sourcepub fn with_single_cert_with_ocsp(
self,
cert_chain: impl ToCertificate,
key_der: impl ToPrivateKey,
ocsp: Vec<u8>,
) -> QuicServerBuilder<TlsServerConfig>
pub fn with_single_cert_with_ocsp( self, cert_chain: impl ToCertificate, key_der: impl ToPrivateKey, ocsp: Vec<u8>, ) -> QuicServerBuilder<TlsServerConfig>
Sets a single certificate chain, matching private key and optional OCSP response. This certificate and key is used for all subsequent connections, irrespective of things like SNI hostname.
Read TlsServerConfigBuilder::with_single_cert_with_ocsp
for more.
Sourcepub fn enable_sni(self) -> QuicServerSniBuilder<TlsServerConfig>
pub fn enable_sni(self) -> QuicServerSniBuilder<TlsServerConfig>
Enable TLS SNI (Server Name Indication) extensions.
Source§impl QuicServerBuilder<ServerConfig>
impl QuicServerBuilder<ServerConfig>
Sourcepub fn with_alpns(
self,
alpn: impl IntoIterator<Item = impl Into<Vec<u8>>>,
) -> Self
pub fn with_alpns( self, alpn: impl IntoIterator<Item = impl Into<Vec<u8>>>, ) -> Self
Specify the [alpn-protocol-ids] that the server supports.
If you call this multiple times, all the alpn_protocol
will be used.
If you never call this method, we will not do ALPN with the client.
Sourcepub fn listen(self, addresses: impl ToSocketAddrs) -> Result<Arc<QuicServer>>
pub fn listen(self, addresses: impl ToSocketAddrs) -> Result<Arc<QuicServer>>
Start to listen for incoming connections.
§Bind Interfaces
The server will bind interfaces from the given addresses, receive datagrams from them, and prevent the interfaces from being automatically released.
The server must successfully bind all given interfaces when it is created, otherwise this method will immediately return an error and the server will not be started.
The server can be created without binding any interface.
You can additionally bind new interfaces after server launched by calling QuicServer::add_interface
.
§Accept Conenctions
By default, the server will accept connections from all interfaces (not only those bound to the quic server, but also those bound to other quic clients).
If strict mode is used, the server will only accept connections from the interface the server is bound to. This is closer to traditional server behavior.
By calling the QuicServer::accept
method, you can get all connections connected to the server.
The QUIC protocol handshake will be completed automatically in the background.
The connection obtained through accpet may not have completed the handshake yet.
§Shutdown
When the QuicServer
is dropped or QuicServer::shutdown
is called,
the server will stop listening for incoming connections,
and you can start a new server by calling the this method again.
Note: There can be only one server running at the same time, so this method will return an error if there is already a server running.