diff --git a/src/config.rs b/src/config.rs index 7da8c3592..0d995ea67 100644 --- a/src/config.rs +++ b/src/config.rs @@ -3000,6 +3000,7 @@ pub mod keys { pub const OPTION_ENABLE_PORT_FORWARD_MUX: &str = "enable-port-forward-mux"; pub const OPTION_ENABLE_WEBRTC: &str = "enable-webrtc"; pub const OPTION_ALLOW_KCP_CC: &str = "allow-kcp-congestion-control"; + pub const OPTION_ALLOW_WEBRTC_CC: &str = "allow-webrtc-congestion-control"; pub const OPTION_HIDE_USERNAME_ON_CARD: &str = "hide-username-on-card"; pub const OPTION_HIDE_HELP_CARDS: &str = "hide-help-cards"; pub const OPTION_DEFAULT_CONNECT_PASSWORD: &str = "default-connect-password"; @@ -3208,6 +3209,7 @@ pub mod keys { OPTION_KEEP_AWAKE_DURING_INCOMING_SESSIONS, OPTION_ALLOW_AUTO_UPDATE, OPTION_ALLOW_KCP_CC, + OPTION_ALLOW_WEBRTC_CC, ]; // BUILDIN_SETTINGS diff --git a/src/webrtc.rs b/src/webrtc.rs index b0c9cb69f..57c609e8d 100644 --- a/src/webrtc.rs +++ b/src/webrtc.rs @@ -473,6 +473,12 @@ impl WebRTCStream { }) } + #[inline] + fn get_cc_enabled() -> bool { + let k = config::keys::OPTION_ALLOW_WEBRTC_CC; + config::option2bool(k, &config::Config::get_option(k)) + } + #[inline] fn get_ice_servers() -> Vec { Self::parse_ice_servers(&config::Config::get_option( @@ -599,6 +605,11 @@ impl WebRTCStream { IpAddr::V4(_) => true, })); + // KCP's nc=1 profile by default, with the same opt-in to a congestion window as + // `allow-kcp-congestion-control`, for the reason given at `get_kcp_cc_enabled`. Set per + // connection so the option takes effect on the next session, not the next start. + webrtc::sctp::association::set_no_congestion_control(!Self::get_cc_enabled()); + // Create the API object let api = APIBuilder::new().with_setting_engine(s).build();