summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSebastian Holmin <sebastian.holmin@mullvad.net>2025-09-02 14:09:29 +0200
committerSebastian Holmin <sebastian.holmin@mullvad.net>2025-09-10 09:58:24 +0200
commitf3f5eccff6049befc6dd32aaf09c243e994866c8 (patch)
tree8db599c7acb3f9d43ed690fbc9e81e42de36994a
parent55ee56dc97208c3edc78e4774115636bb6ded61b (diff)
downloadmullvadvpn-f3f5eccff6049befc6dd32aaf09c243e994866c8.tar.xz
mullvadvpn-f3f5eccff6049befc6dd32aaf09c243e994866c8.zip
Add offending query to relay select err
-rw-r--r--mullvad-relay-selector/src/error.rs6
-rw-r--r--mullvad-relay-selector/src/relay_selector/mod.rs21
2 files changed, 14 insertions, 13 deletions
diff --git a/mullvad-relay-selector/src/error.rs b/mullvad-relay-selector/src/error.rs
index e2de09eac0..5dc7747f6c 100644
--- a/mullvad-relay-selector/src/error.rs
+++ b/mullvad-relay-selector/src/error.rs
@@ -1,7 +1,7 @@
//! Definition of relay selector errors
#![allow(dead_code)]
-use crate::{detailer, relay_selector::relays::WireguardConfig};
+use crate::{detailer, query::RelayQuery, relay_selector::relays::WireguardConfig};
use mullvad_types::{relay_constraints::MissingCustomBridgeSettings, relay_list::Relay};
use talpid_types::net::IpVersion;
@@ -16,8 +16,8 @@ pub enum Error {
#[error("The combination of relay constraints is invalid")]
InvalidConstraints,
- #[error("No relays matching current constraints")]
- NoRelay,
+ #[error("No relays matching current constraints: {0:?}")]
+ NoRelay(Box<RelayQuery>),
#[error("No bridges matching current constraints")]
NoBridge,
diff --git a/mullvad-relay-selector/src/relay_selector/mod.rs b/mullvad-relay-selector/src/relay_selector/mod.rs
index 118cda99d4..5500fb3836 100644
--- a/mullvad-relay-selector/src/relay_selector/mod.rs
+++ b/mullvad-relay-selector/src/relay_selector/mod.rs
@@ -603,7 +603,7 @@ impl RelaySelector {
/// This function defines the merge between a set of pre-defined queries and `user_preferences`
/// for the given `retry_attempt`.
///
- /// This algorithm will loop back to the start of `retry_order` if `retry_attempt <
+ /// This algorithm will loop back to the start of `retry_order` if `retry_attempt >
/// retry_order.len()`. If `user_preferences` is not compatible with any of the pre-defined
/// queries in `retry_order`, `user_preferences` is returned.
///
@@ -630,7 +630,7 @@ impl RelaySelector {
.filter(|query| Self::get_relay_inner(query, parsed_relays, user_config.custom_lists).is_ok())
.cycle() // If the above filters remove all relays, cycle will also return an empty iterator
.nth(retry_attempt)
- .ok_or(Error::NoRelay)
+ .ok_or_else(|| Error::NoRelay(Box::new(user_query)))
}
/// "Execute" the given query, yielding a final set of relays and/or bridges which the VPN
@@ -735,7 +735,7 @@ impl RelaySelector {
)?;
WireguardConfig::from(multihop)
} else {
- return Err(Error::NoRelay);
+ return Err(Error::NoRelay(Box::new(query.clone())));
}
}
}
@@ -791,7 +791,8 @@ impl RelaySelector {
let exit_candidates =
filter_matching_relay_list(&exit_relay_query, parsed_relays, custom_lists);
- let exit = helpers::pick_random_relay(&exit_candidates).ok_or(Error::NoRelay)?;
+ let exit = helpers::pick_random_relay(&exit_candidates)
+ .ok_or_else(|| Error::NoRelay(Box::new(exit_relay_query)))?;
// generate a list of potential entry relays, disregarding any location constraint
let mut entry_query = query.clone();
@@ -815,8 +816,8 @@ impl RelaySelector {
.take_while(|relay| relay.distance <= smallest_distance)
.map(|relay_with_distance| relay_with_distance.relay)
.collect_vec();
- let entry =
- helpers::pick_random_relay_excluding(&entry_candidates, exit).ok_or(Error::NoRelay)?;
+ let entry = helpers::pick_random_relay_excluding(&entry_candidates, exit)
+ .ok_or_else(|| Error::NoRelay(Box::new(entry_query)))?;
Ok(Multihop::new(entry.clone(), exit.clone()))
}
@@ -880,7 +881,7 @@ impl RelaySelector {
exit_candidates.as_slice(),
entry_candidates.as_slice(),
)
- .ok_or(Error::NoRelay)?;
+ .ok_or_else(|| Error::NoRelay(Box::new(query.clone())))?;
Ok(Multihop::new(entry.clone(), exit.clone()))
}
}
@@ -987,8 +988,8 @@ impl RelaySelector {
parsed_relays: &RelayList,
) -> Result<GetRelay, Error> {
assert_eq!(query.tunnel_protocol(), TunnelType::OpenVpn);
- let exit =
- Self::choose_openvpn_relay(query, custom_lists, parsed_relays).ok_or(Error::NoRelay)?;
+ let exit = Self::choose_openvpn_relay(query, custom_lists, parsed_relays)
+ .ok_or_else(|| Error::NoRelay(Box::new(query.clone())))?;
let endpoint = Self::get_openvpn_endpoint(query, &exit, parsed_relays)?;
let bridge = Self::get_openvpn_bridge(
query,
@@ -1116,7 +1117,7 @@ impl RelaySelector {
Some(location) => Self::get_proximate_bridge(bridges, location),
None => helpers::pick_random_relay(&bridges)
.cloned()
- .ok_or(Error::NoRelay),
+ .ok_or(Error::NoBridge),
}?;
let endpoint = detailer::bridge_endpoint(bridge_data, &bridge).ok_or(Error::NoBridge)?;
Ok((endpoint, bridge))