diff options
6 files changed, 29 insertions, 6 deletions
diff --git a/mullvad-api/src/relay_list.rs b/mullvad-api/src/relay_list.rs index 6fdc073efd..f36a375b85 100644 --- a/mullvad-api/src/relay_list.rs +++ b/mullvad-api/src/relay_list.rs @@ -363,6 +363,7 @@ impl WireGuardRelay { daita: self.features.daita.map(|_| true).unwrap_or(self.daita), shadowsocks_extra_addr_in: HashSet::from_iter(self.shadowsocks_extra_addr_in), quic: self.features.quic.map(relay_list::Quic::from), + lwo: self.features.lwo.is_some(), }); into_mullvad_relay(relay, location, endpoint_data) @@ -374,6 +375,7 @@ impl WireGuardRelay { struct Features { daita: Option<Daita>, quic: Option<Quic>, + lwo: Option<Lwo>, } /// DAITA doesn't have any configuration options (exposed by the API). @@ -405,6 +407,12 @@ impl From<Quic> for relay_list::Quic { } } +/// LWO doesn't have any configuration options (exposed by the API). +/// +/// Note, an empty struct is not the same as an empty tuple struct according to serde_json! +#[derive(Debug, Clone, serde::Deserialize)] +struct Lwo {} + #[derive(Debug, serde::Deserialize)] struct Bridges { shadowsocks: Vec<relay_list::ShadowsocksEndpointData>, diff --git a/mullvad-management-interface/proto/management_interface.proto b/mullvad-management-interface/proto/management_interface.proto index 207b977070..1b38faaacc 100644 --- a/mullvad-management-interface/proto/management_interface.proto +++ b/mullvad-management-interface/proto/management_interface.proto @@ -744,6 +744,8 @@ message Relay { bool daita = 2; Quic quic = 3; repeated string shadowsocks_extra_addr_in = 4; + bool lwo = 5; + } oneof data { diff --git a/mullvad-management-interface/src/types/conversions/relay_list.rs b/mullvad-management-interface/src/types/conversions/relay_list.rs index f7979725fe..329ddedf24 100644 --- a/mullvad-management-interface/src/types/conversions/relay_list.rs +++ b/mullvad-management-interface/src/types/conversions/relay_list.rs @@ -141,6 +141,7 @@ impl From<mullvad_types::relay_list::Relay> for proto::Relay { daita, shadowsocks_extra_addr_in, quic, + lwo: data.lwo, }) } MullvadEndpointData::Bridge => Data::Bridge(Bridge {}), @@ -306,6 +307,7 @@ impl TryFrom<proto::Relay> for mullvad_types::relay_list::Relay { public_key, daita, quic, + lwo: wireguard.lwo, shadowsocks_extra_addr_in, }; MullvadEndpointData::Wireguard(data) diff --git a/mullvad-relay-selector/src/relay_selector/helpers.rs b/mullvad-relay-selector/src/relay_selector/helpers.rs index 977b92b26e..6e0ceacfde 100644 --- a/mullvad-relay-selector/src/relay_selector/helpers.rs +++ b/mullvad-relay-selector/src/relay_selector/helpers.rs @@ -222,10 +222,9 @@ pub fn get_lwo_obfuscator( relay: Relay, endpoint: &MullvadWireguardEndpoint, ) -> Option<(ObfuscatorConfig, Relay)> { - let _wg = relay.wireguard()?; - - // TODO: check if LWO is supported on this relay - + if !relay.wireguard()?.lwo { + return None; + } let ip = match endpoint.peer.endpoint { SocketAddr::V4(_) => IpAddr::V4(relay.ipv4_addr_in), SocketAddr::V6(_) => IpAddr::V6(relay.ipv6_addr_in?), diff --git a/mullvad-relay-selector/src/relay_selector/matcher.rs b/mullvad-relay-selector/src/relay_selector/matcher.rs index e0efca03a4..7ccb9a6d68 100644 --- a/mullvad-relay-selector/src/relay_selector/matcher.rs +++ b/mullvad-relay-selector/src/relay_selector/matcher.rs @@ -145,8 +145,8 @@ fn filter_on_obfuscation( }, None => false, }, - // TODO: This is only enabled on some relays - ObfuscationQuery::Lwo => true, + // LWO is only enabled on some relays + ObfuscationQuery::Lwo => endpoint_data.lwo, // Other relays are compatible with this query ObfuscationQuery::Off | ObfuscationQuery::Auto | ObfuscationQuery::Udp2tcp(_) => true, } diff --git a/mullvad-types/src/relay_list.rs b/mullvad-types/src/relay_list.rs index d28ed88e74..0d22e64f46 100644 --- a/mullvad-types/src/relay_list.rs +++ b/mullvad-types/src/relay_list.rs @@ -255,6 +255,7 @@ impl PartialEq for Relay { /// # daita: false, /// # shadowsocks_extra_addr_in: Default::default(), /// # quic: None, + /// # lwo: false, /// # }), /// # location: mullvad_types::location::Location { /// # country: "Sweden".to_string(), @@ -351,6 +352,9 @@ pub struct WireguardRelayEndpointData { /// Parameters for connecting to the masque-proxy running on the relay. #[serde(default)] pub quic: Option<Quic>, + /// Whether the relay supports LWO + #[serde(default)] + pub lwo: bool, /// Optional IP addresses used by Shadowsocks #[serde(default)] pub shadowsocks_extra_addr_in: HashSet<IpAddr>, @@ -362,6 +366,7 @@ impl WireguardRelayEndpointData { public_key, daita: Default::default(), quic: Default::default(), + lwo: Default::default(), shadowsocks_extra_addr_in: Default::default(), } } @@ -380,6 +385,13 @@ impl WireguardRelayEndpointData { } } + pub fn set_lwo(self, enabled: bool) -> Self { + Self { + lwo: enabled, + ..self + } + } + /// Add `in_addrs` to the existing shadowsocks extra in addressess. pub fn add_shadowsocks_extra_in_addrs(self, in_addrs: impl Iterator<Item = IpAddr>) -> Self { let in_addrs = self.shadowsocks_extra_in_addrs().copied().chain(in_addrs); |
