quiche

Struct Config

Source
pub struct Config { /* private fields */ }
Expand description

Stores configuration shared between multiple connections.

Implementations§

Source§

impl Config

Source

pub fn new(version: u32) -> Result<Config>

Creates a config object with the given version.

§Examples:
let config = quiche::Config::new(quiche::PROTOCOL_VERSION)?;
Source

pub fn with_boring_ssl_ctx_builder( version: u32, tls_ctx_builder: SslContextBuilder, ) -> Result<Config>

Available on crate feature boringssl-boring-crate only.

Creates a config object with the given version and SslContextBuilder.

This is useful for applications that wish to manually configure SslContextBuilder.

Source

pub fn load_cert_chain_from_pem_file(&mut self, file: &str) -> Result<()>

Configures the given certificate chain.

The content of file is parsed as a PEM-encoded leaf certificate, followed by optional intermediate certificates.

§Examples:
config.load_cert_chain_from_pem_file("/path/to/cert.pem")?;
Source

pub fn load_priv_key_from_pem_file(&mut self, file: &str) -> Result<()>

Configures the given private key.

The content of file is parsed as a PEM-encoded private key.

§Examples:
config.load_priv_key_from_pem_file("/path/to/key.pem")?;
Source

pub fn load_verify_locations_from_file(&mut self, file: &str) -> Result<()>

Specifies a file where trusted CA certificates are stored for the purposes of certificate verification.

The content of file is parsed as a PEM-encoded certificate chain.

§Examples:
config.load_verify_locations_from_file("/path/to/cert.pem")?;
Source

pub fn load_verify_locations_from_directory(&mut self, dir: &str) -> Result<()>

Specifies a directory where trusted CA certificates are stored for the purposes of certificate verification.

The content of dir a set of PEM-encoded certificate chains.

§Examples:
config.load_verify_locations_from_directory("/path/to/certs")?;
Source

pub fn verify_peer(&mut self, verify: bool)

Configures whether to verify the peer’s certificate.

The default value is true for client connections, and false for server ones.

Note that on the server-side, enabling verification of the peer will trigger a certificate request and make authentication errors fatal, but will still allow anonymous clients (i.e. clients that don’t present a certificate at all). Servers can check whether a client presented a certificate by calling peer_cert() if they need to.

Source

pub fn discover_pmtu(&mut self, discover: bool)

Configures whether to do path MTU discovery.

The default value is false.

Source

pub fn grease(&mut self, grease: bool)

Configures whether to send GREASE values.

The default value is true.

Source

pub fn log_keys(&mut self)

Enables logging of secrets.

When logging is enabled, the set_keylog() method must be called on the connection for its cryptographic secrets to be logged in the keylog format to the specified writer.

Source

pub fn set_ticket_key(&mut self, key: &[u8]) -> Result<()>

Configures the session ticket key material.

On the server this key will be used to encrypt and decrypt session tickets, used to perform session resumption without server-side state.

By default a key is generated internally, and rotated regularly, so applications don’t need to call this unless they need to use a specific key (e.g. in order to support resumption across multiple servers), in which case the application is also responsible for rotating the key to provide forward secrecy.

Source

pub fn enable_early_data(&mut self)

Enables sending or receiving early data.

Source

pub fn set_application_protos(&mut self, protos_list: &[&[u8]]) -> Result<()>

Configures the list of supported application protocols.

On the client this configures the list of protocols to send to the server as part of the ALPN extension.

On the server this configures the list of supported protocols to match against the client-supplied list.

Applications must set a value, but no default is provided.

§Examples:
config.set_application_protos(&[b"http/1.1", b"http/0.9"]);
Source

pub fn set_application_protos_wire_format( &mut self, protos: &[u8], ) -> Result<()>

Configures the list of supported application protocols using wire format.

The list of protocols protos must be a series of non-empty, 8-bit length-prefixed strings.

See set_application_protos for more background about application protocols.

§Examples:
config.set_application_protos_wire_format(b"\x08http/1.1\x08http/0.9")?;
Source

pub fn set_max_amplification_factor(&mut self, v: usize)

Sets the anti-amplification limit factor.

The default value is 3.

Source

pub fn set_max_idle_timeout(&mut self, v: u64)

Sets the max_idle_timeout transport parameter, in milliseconds.

The default value is infinite, that is, no timeout is used.

Source

pub fn set_max_recv_udp_payload_size(&mut self, v: usize)

Sets the max_udp_payload_size transport parameter.

The default value is 65527.

Source

pub fn set_max_send_udp_payload_size(&mut self, v: usize)

Sets the maximum outgoing UDP payload size.

The default and minimum value is 1200.

Source

pub fn set_initial_max_data(&mut self, v: u64)

Sets the initial_max_data transport parameter.

When set to a non-zero value quiche will only allow at most v bytes of incoming stream data to be buffered for the whole connection (that is, data that is not yet read by the application) and will allow more data to be received as the buffer is consumed by the application.

When set to zero, either explicitly or via the default, quiche will not give any flow control to the peer, preventing it from sending any stream data.

The default value is 0.

Source

pub fn set_initial_max_stream_data_bidi_local(&mut self, v: u64)

Sets the initial_max_stream_data_bidi_local transport parameter.

When set to a non-zero value quiche will only allow at most v bytes of incoming stream data to be buffered for each locally-initiated bidirectional stream (that is, data that is not yet read by the application) and will allow more data to be received as the buffer is consumed by the application.

When set to zero, either explicitly or via the default, quiche will not give any flow control to the peer, preventing it from sending any stream data.

The default value is 0.

Source

pub fn set_initial_max_stream_data_bidi_remote(&mut self, v: u64)

Sets the initial_max_stream_data_bidi_remote transport parameter.

When set to a non-zero value quiche will only allow at most v bytes of incoming stream data to be buffered for each remotely-initiated bidirectional stream (that is, data that is not yet read by the application) and will allow more data to be received as the buffer is consumed by the application.

When set to zero, either explicitly or via the default, quiche will not give any flow control to the peer, preventing it from sending any stream data.

The default value is 0.

Source

pub fn set_initial_max_stream_data_uni(&mut self, v: u64)

Sets the initial_max_stream_data_uni transport parameter.

When set to a non-zero value quiche will only allow at most v bytes of incoming stream data to be buffered for each unidirectional stream (that is, data that is not yet read by the application) and will allow more data to be received as the buffer is consumed by the application.

When set to zero, either explicitly or via the default, quiche will not give any flow control to the peer, preventing it from sending any stream data.

The default value is 0.

Source

pub fn set_initial_max_streams_bidi(&mut self, v: u64)

Sets the initial_max_streams_bidi transport parameter.

When set to a non-zero value quiche will only allow v number of concurrent remotely-initiated bidirectional streams to be open at any given time and will increase the limit automatically as streams are completed.

When set to zero, either explicitly or via the default, quiche will not not allow the peer to open any bidirectional streams.

A bidirectional stream is considered completed when all incoming data has been read by the application (up to the fin offset) or the stream’s read direction has been shutdown, and all outgoing data has been acked by the peer (up to the fin offset) or the stream’s write direction has been shutdown.

The default value is 0.

Source

pub fn set_initial_max_streams_uni(&mut self, v: u64)

Sets the initial_max_streams_uni transport parameter.

When set to a non-zero value quiche will only allow v number of concurrent remotely-initiated unidirectional streams to be open at any given time and will increase the limit automatically as streams are completed.

When set to zero, either explicitly or via the default, quiche will not not allow the peer to open any unidirectional streams.

A unidirectional stream is considered completed when all incoming data has been read by the application (up to the fin offset) or the stream’s read direction has been shutdown.

The default value is 0.

Source

pub fn set_ack_delay_exponent(&mut self, v: u64)

Sets the ack_delay_exponent transport parameter.

The default value is 3.

Source

pub fn set_max_ack_delay(&mut self, v: u64)

Sets the max_ack_delay transport parameter.

The default value is 25.

Source

pub fn set_active_connection_id_limit(&mut self, v: u64)

Sets the active_connection_id_limit transport parameter.

The default value is 2. Lower values will be ignored.

Source

pub fn set_disable_active_migration(&mut self, v: bool)

Sets the disable_active_migration transport parameter.

The default value is false.

Source

pub fn set_cc_algorithm_name(&mut self, name: &str) -> Result<()>

Sets the congestion control algorithm used by string.

The default value is cubic. On error Error::CongestionControl will be returned.

§Examples:
config.set_cc_algorithm_name("reno");
Source

pub fn set_initial_congestion_window_packets(&mut self, packets: usize)

Sets initial congestion window size in terms of packet count.

The default value is 10.

Source

pub fn set_cc_algorithm(&mut self, algo: CongestionControlAlgorithm)

Sets the congestion control algorithm used.

The default value is CongestionControlAlgorithm::CUBIC.

Source

pub fn enable_hystart(&mut self, v: bool)

Configures whether to enable HyStart++.

The default value is true.

Source

pub fn enable_pacing(&mut self, v: bool)

Configures whether to enable pacing.

The default value is true.

Source

pub fn set_max_pacing_rate(&mut self, v: u64)

Sets the max value for pacing rate.

By default pacing rate is not limited.

Source

pub fn enable_dgram( &mut self, enabled: bool, recv_queue_len: usize, send_queue_len: usize, )

Configures whether to enable receiving DATAGRAM frames.

When enabled, the max_datagram_frame_size transport parameter is set to 65536 as recommended by draft-ietf-quic-datagram-01.

The default is false.

Source

pub fn set_path_challenge_recv_max_queue_len(&mut self, queue_len: usize)

Configures the max number of queued received PATH_CHALLENGE frames.

When an endpoint receives a PATH_CHALLENGE frame and the queue is full, the frame is discarded.

The default is 3.

Source

pub fn set_max_connection_window(&mut self, v: u64)

Sets the maximum size of the connection window.

The default value is MAX_CONNECTION_WINDOW (24MBytes).

Source

pub fn set_max_stream_window(&mut self, v: u64)

Sets the maximum size of the stream window.

The default value is MAX_STREAM_WINDOW (16MBytes).

Source

pub fn set_stateless_reset_token(&mut self, v: Option<u128>)

Sets the initial stateless reset token.

This value is only advertised by servers. Setting a stateless retry token as a client has no effect on the connection.

The default value is None.

Source

pub fn set_disable_dcid_reuse(&mut self, v: bool)

Sets whether the QUIC connection should avoid reusing DCIDs over different paths.

When set to true, it ensures that a destination Connection ID is never reused on different paths. Such behaviour may lead to connection stall if the peer performs a non-voluntary migration (e.g., NAT rebinding) and does not provide additional destination Connection IDs to handle such event.

The default value is false.

Auto Trait Implementations§

§

impl Freeze for Config

§

impl RefUnwindSafe for Config

§

impl Send for Config

§

impl Sync for Config

§

impl Unpin for Config

§

impl UnwindSafe for Config

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.