Skip to content

Commit

Permalink
(feat) quic: Add path MTU discovery configuration.
Browse files Browse the repository at this point in the history
# Conflicts:
#	transports/quic/src/config.rs
  • Loading branch information
shamil-gadelshin committed Nov 2, 2023
1 parent f265f39 commit a4920ed
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion transports/quic/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.

use quinn::VarInt;
use quinn::{MtuDiscoveryConfig, VarInt};
use std::{sync::Arc, time::Duration};

/// Config for the transport.
Expand Down Expand Up @@ -61,6 +61,9 @@ pub struct Config {
client_tls_config: Arc<rustls::ClientConfig>,
/// TLS server config for the inner [`quinn::ServerConfig`].
server_tls_config: Arc<rustls::ServerConfig>,

/// Parameters governing MTU discovery. See [`MtuDiscoveryConfig`] for details.
path_mtu_discovery_config: Option<MtuDiscoveryConfig>,
}

impl Config {
Expand All @@ -80,8 +83,17 @@ impl Config {

// Ensure that one stream is not consuming the whole connection.
max_stream_data: 10_000_000,
path_mtu_discovery_config: Some(Default::default()),
}
}

pub fn path_mtu_discovery_config(
mut self,
path_mtu_discovery_config: Option<MtuDiscoveryConfig>,
) -> Self {
self.path_mtu_discovery_config = path_mtu_discovery_config;
self
}
}

/// Represents the inner configuration for [`quinn`].
Expand All @@ -104,6 +116,7 @@ impl From<Config> for QuinnConfig {
max_stream_data,
support_draft_29,
handshake_timeout: _,
path_mtu_discovery_config,
} = config;
let mut transport = quinn::TransportConfig::default();
// Disable uni-directional streams.
Expand All @@ -116,6 +129,7 @@ impl From<Config> for QuinnConfig {
transport.allow_spin(false);
transport.stream_receive_window(max_stream_data.into());
transport.receive_window(max_connection_data.into());
transport.mtu_discovery_config(path_mtu_discovery_config);
let transport = Arc::new(transport);

let mut server_config = quinn::ServerConfig::with_crypto(server_tls_config);
Expand Down

0 comments on commit a4920ed

Please sign in to comment.