diff options
| author | Joakim Hulthe <joakim.hulthe@mullvad.net> | 2024-08-19 17:11:11 +0200 |
|---|---|---|
| committer | Joakim Hulthe <joakim.hulthe@mullvad.net> | 2024-09-17 11:29:29 +0200 |
| commit | 31a215bee9954194db9b5b0d90c285fa62d7b6ea (patch) | |
| tree | e6a387f209c9b22d9345b8a3c7af09037a987669 | |
| parent | 3fac6f5f6d84ee65ba015f900ab5436e0f48cc01 (diff) | |
| download | mullvadvpn-31a215bee9954194db9b5b0d90c285fa62d7b6ea.tar.xz mullvadvpn-31a215bee9954194db9b5b0d90c285fa62d7b6ea.zip | |
Implement daita use_anywhere feature indicator
| -rw-r--r-- | mullvad-types/src/features.rs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/mullvad-types/src/features.rs b/mullvad-types/src/features.rs index 0a87262666..592d2382e2 100644 --- a/mullvad-types/src/features.rs +++ b/mullvad-types/src/features.rs @@ -163,6 +163,18 @@ pub fn compute_feature_indicators( #[cfg(daita)] let daita = endpoint.daita; + #[cfg(daita)] + let daita_use_anywhere = + if let crate::relay_constraints::RelaySettings::Normal(constraints) = + &settings.relay_settings + { + // Detect whether we're using "use_anywhere" by checking if multihop is + // in use but not explicitly enabled. + daita && multihop && !constraints.wireguard_constraints.use_multihop + } else { + false + }; + vec![ (quantum_resistant, FeatureIndicator::QuantumResistance), (multihop, FeatureIndicator::Multihop), @@ -171,6 +183,8 @@ pub fn compute_feature_indicators( (mtu, FeatureIndicator::CustomMtu), #[cfg(daita)] (daita, FeatureIndicator::Daita), + #[cfg(daita)] + (daita_use_anywhere, FeatureIndicator::DaitaUseAnywhere), ] } }; @@ -192,6 +206,8 @@ mod tests { Endpoint, ObfuscationEndpoint, TransportProtocol, }; + use crate::relay_constraints::RelaySettings; + use super::*; #[test] @@ -304,6 +320,9 @@ mod tests { address: SocketAddr::from(([1, 2, 3, 4], 443)), protocol: TransportProtocol::Tcp, }); + if let RelaySettings::Normal(constraints) = &mut settings.relay_settings { + constraints.wireguard_constraints.use_multihop = true; + }; expected_indicators.0.insert(FeatureIndicator::Multihop); assert_eq!( compute_feature_indicators(&settings, &endpoint, false), @@ -345,6 +364,18 @@ mod tests { compute_feature_indicators(&settings, &endpoint, false), expected_indicators ); + + if let RelaySettings::Normal(constraints) = &mut settings.relay_settings { + constraints.wireguard_constraints.use_multihop = false; + }; + expected_indicators + .0 + .insert(FeatureIndicator::DaitaUseAnywhere); + assert_eq!( + compute_feature_indicators(&settings, &endpoint, false), + expected_indicators, + "DaitaUseAnywhere should be enable" + ); } // NOTE: If this match statement fails to compile, it means that a new feature indicator has @@ -364,6 +395,7 @@ mod tests { FeatureIndicator::CustomMtu => {} FeatureIndicator::CustomMssFix => {} FeatureIndicator::Daita => {} + FeatureIndicator::DaitaUseAnywhere => {} } } } |
