tor_relay_selection/config.rs
1//! Define configuration structures used for relay selection.
2
3use std::collections::HashSet;
4
5/// Configuration object for building relay restrictions.
6///
7/// This object can affect the interpretation of various usages and restrictions.
8#[allow(clippy::exhaustive_structs)]
9pub struct RelaySelectionConfig<'a> {
10 /// A set of ports that require Stable relays.
11 pub long_lived_ports: &'a HashSet<u16>,
12
13 /// Configuration for which addresses are considered "too close"
14 /// to share a circuit.
15 pub subnet_config: tor_netdir::SubnetConfig,
16}
17
18impl<'a> RelaySelectionConfig<'a> {
19 /// Return true if `port` requires us to use relays with the Stable flag.
20 pub(crate) fn port_requires_stable_flag(&self, port: u16) -> bool {
21 self.long_lived_ports.contains(&port)
22 }
23}